You are here

public function BlockClassFeaturesTestCase::testFeatureDisplayClass in Block Class 7.2

Test how Block Class 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_class.test, line 298
Test the Block Class module.

Class

BlockClassFeaturesTestCase
Test Block Class integration with Features through FE Block.

Code

public function testFeatureDisplayClass() {

  // Block classes exported to the Test Feature module.
  $test_classes = 'fe_block-class1 fe_block-class2 fe_block-class3';

  // Test helper feature machine name.
  $test_feature = 'block_class_fe_block_test';

  // Browse to the front page and check Block's CSS classes configuration.
  $this
    ->drupalGet('');

  // Check if feature's Block CSS classes could be found.
  $this
    ->assertPattern('/class=\\"(.*?)' . $test_classes . '(.*?)\\"/', format_string('The CSS classes from exported feature were found: @css_classes', array(
    '@css_classes' => $test_classes,
  )));

  // Check Block's configuration form css_class field value.
  $this
    ->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
  $this
    ->assertFieldByName('css_class', $test_classes, format_string('The CSS classes from exported feature were found for the field <em>css_class</em> in the Block\'s configuration page: @css_classes', array(
    '@css_classes' => $test_classes,
  )));

  // Run a standard Update/Display Test check with Anon.
  $this
    ->assertUpdateBlockClass(TRUE);

  // Ensure Feature's state is overridden 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 Class 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 Class 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 CSS classes configuration.
  $this
    ->drupalGet('');

  // Check if feature's Block CSS classes could be found.
  $this
    ->assertPattern('/class=\\"(.*?)' . $test_classes . '(.*?)\\"/', format_string('After reverting the feature, the CSS classes from exported feature were found: @css_classes', array(
    '@css_classes' => $test_classes,
  )));

  // Check Block's configuration form css_class field value.
  $this
    ->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
  $this
    ->assertFieldByName('css_class', $test_classes, format_string('After reverting the feature, the CSS classes from exported feature were found for the field <em>css_class</em> in the Block\'s configuration page: @css_classes', array(
    '@css_classes' => $test_classes,
  )));
}