BlockHtmlIdTest.php

Definition of Drupal\block\Tests\BlockHtmlIdTest.

Namespace

Drupal\block\Tests

File

drupal/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
View source
<?php

/**
 * @file
 * Definition of Drupal\block\Tests\BlockHtmlIdTest.
 */
namespace Drupal\block\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Test block HTML id validity.
 */
class BlockHtmlIdTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array(
    'block',
    'block_test',
  );
  public static function getInfo() {
    return array(
      'name' => 'Block HTML id',
      'description' => 'Test block HTML id validity.',
      'group' => 'Block',
    );
  }
  function setUp() {
    parent::setUp();

    // Create an admin user, log in and enable test blocks.
    $this->admin_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
      'access administration pages',
    ));
    $this
      ->drupalLogin($this->admin_user);

    // Enable our test block.
    $edit['blocks[block_test_test_html_id][region]'] = 'sidebar_first';
    $this
      ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

    // Make sure the block has some content so it will appear
    $current_content = $this
      ->randomName();
    state()
      ->set('block_test.content', $current_content);
  }

  /**
   * Test valid HTML id.
   */
  function testHtmlId() {
    $this
      ->drupalGet('');
    $this
      ->assertRaw('block-block-test-test-html-id', 'HTML id for test block is valid.');
  }

}

Classes

Namesort descending Description
BlockHtmlIdTest Test block HTML id validity.