You are here

public function BlockClassMenuBlockTestCase::testMenuBlockDisplayClass in Block Class 7.2

Create, update and display a Menu Block to ensure CSS class is found.

A Menu Block is added through the user interface. It is then updated and displayed several times with logged in or anonymous user.

File

./block_class.test, line 376
Test the Block Class module.

Class

BlockClassMenuBlockTestCase
Test Block Class integration with Menu Block.

Code

public function testMenuBlockDisplayClass() {

  // Test with three random class names.
  $css_classes = implode(' ', array(
    $this
      ->randomName(8),
    $this
      ->randomName(8),
    $this
      ->randomName(8),
  ));

  // Start with the creation of a new Menu Block.
  $this
    ->drupalPost("admin/structure/block/add-menu-block", array(
    'css_class' => $css_classes,
    'menu_name' => 'navigation',
    'regions[bartik]' => 'content',
  ), t('Save block'));

  // Check if the Block was successfully created.
  $this
    ->assertText(t('The block has been created.'));

  // Browse to the homepage.
  $this
    ->drupalGet('');

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

  // Run the standard tests on the existing Menu Block created above.
  // Edit the block, change the class and check with the anonymous user.
  $this
    ->assertUpdateBlockClass(TRUE);
}