You are here

public function AttributeTest::testPrint in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testPrint()

Tests printing of an attribute.

File

core/tests/Drupal/Tests/Core/Template/AttributeTest.php, line 344
Contains \Drupal\Tests\Core\Template\AttributeTest.

Class

AttributeTest
@coversDefaultClass \Drupal\Core\Template\Attribute @group Template

Namespace

Drupal\Tests\Core\Template

Code

public function testPrint() {
  $attribute = new Attribute(array(
    'class' => array(
      'example-class',
    ),
    'id' => 'example-id',
    'enabled' => TRUE,
  ));
  $content = $this
    ->randomMachineName();
  $html = '<div' . (string) $attribute . '>' . $content . '</div>';
  $this
    ->assertClass('example-class', $html);
  $this
    ->assertNoClass('example-class2', $html);
  $this
    ->assertID('example-id', $html);
  $this
    ->assertNoID('example-id2', $html);
  $this
    ->assertTrue(strpos($html, 'enabled') !== FALSE);
}