public function BlockAttributesPermissionTestCase::testPermission in Block Attributes 7
Ensure Block Attributes fields only appear with the right permissions.
Test if a user without 'administer block attributes' permission has access to the Block Attributes fields on the block configuration page.
File
- ./
block_attributes.test, line 284 - Test the Block Attributes module.
Class
- BlockAttributesPermissionTestCase
- Test Block Attributes permissions.
Code
public function testPermission() {
// Browse to the "Main page content" block editing form page.
$this
->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
// Get Block Attributes testing data.
$block_attributes = $this
->getBlockAttributesTestingData();
// The Title field is not part of the HTML attributes to be tested.
unset($block_attributes['title']);
// For each attribute name check if the field exists on the page.
foreach ($block_attributes as $key => $value) {
$this
->assertNoFieldByName($key, NULL, format_string('The field <em>@field_name</em> was not found on the page.', array(
'@field_name' => $key,
)));
}
}