public function BlockAttributesFeaturesTestCase::testFeatureDisplayAttributes in Block Attributes 7
Test how Block Attributes reacts when exported to a Feature with FE Block.
Helper Feature's Block configuration settings are imported, updated and the display is tested several times, before reverting the feature.
File
- ./
block_attributes.test, line 409 - Test the Block Attributes module.
Class
- BlockAttributesFeaturesTestCase
- Test Block Attributes integration with Features through FE Block.
Code
public function testFeatureDisplayAttributes() {
// Block attributes exported to the Test Feature module.
$test_attributes = array(
'title' => "Block Attributes Test Who's Online with FE Block",
'attributes[accesskey]' => 'A',
'attributes[align]' => 'right',
'attributes[class]' => 'fe_block-class1 fe_block-class2 fe_block-class3',
'attributes[id]' => 'fe_block-id1',
'attributes[style]' => 'font-weight: bold;text-decoration: underline;',
'attributes[title]' => 'FE Block - Block lvl title test1',
'title_attributes[align]' => 'center',
'title_attributes[class]' => 'fe_block_title-class1 fe_block_title-class2 fe_block_title-class3',
'title_attributes[id]' => 'fe_block_title-id1',
'title_attributes[style]' => 'font-size: 11px; font-weight: normal;',
'title_attributes[title]' => 'FE Block - Block Title title test1',
'content_attributes[align]' => 'left',
'content_attributes[id]' => 'fe_block_content-id1',
'content_attributes[style]' => 'text-align: center;',
'content_attributes[title]' => 'FE Block - Block Content title test1',
);
// Test helper feature machine name.
$test_feature = 'block_attributes_fe_block_test';
// Browse to the front page and check Block's attributes configuration.
$this
->drupalGet('');
// Assert whether Block's attributes could be found on the page.
$this
->assertBlockAttributesDisplay($test_attributes);
// Check Block's configuration form HTML attributes fields values.
$this
->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
foreach ($test_attributes as $key => $value) {
$this
->assertFieldByName($key, $value, format_string('The values from exported feature were found for the field <em>@field_name</em> in the Block\'s configuration page: @field_value', array(
'@field_name' => $key,
'@field_value' => $value,
)));
}
// Run a standard Update/Display Test check with Anon.
$this
->assertUpdateDisplayBlockAttributes(TRUE);
// Ensure Feature's state is overriden for 'fe_block_settings' component.
module_load_include('inc', 'features', 'features.export');
$test_feature_state = features_get_storage($test_feature);
$this
->assertFalse(empty($test_feature_state), 'The state of the <em>Block Attributes FE Block Integration Test Helper</em> feature is <strong>Overridden</strong>.');
$test_feature_states = features_get_component_states(array(
$test_feature,
));
$this
->assertFalse(empty($test_feature_states[$test_feature]['fe_block_settings']), 'The state of the <em>fe_block_settings</em> component of the <em>Block Attributes FE Block Integration Test Helper</em> feature is <strong>Overridden</strong>.');
// Revert feature and check again.
features_revert_module($test_feature);
// Browse to the front page and check Block's attributes configuration.
$this
->drupalGet('');
// Assert whether Block's attributes could be found on the page.
$this
->assertBlockAttributesDisplay($test_attributes);
// Check Block's configuration form HTML attributes fields values.
$this
->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
foreach ($test_attributes as $key => $value) {
$this
->assertFieldByName($key, $value, format_string('The values from exported feature were found for the field <em>@field_name</em> in the Block\'s configuration page: @field_value', array(
'@field_name' => $key,
'@field_value' => $value,
)));
}
}