function WebAssertTest::testPageContainsNoDuplicateId

Same name in this branch
  1. 10 core/tests/Drupal/FunctionalTests/WebAssertTest.php \Drupal\FunctionalTests\WebAssertTest::testPageContainsNoDuplicateId()
Same name in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/WebAssertTest.php \Drupal\FunctionalTests\WebAssertTest::testPageContainsNoDuplicateId()
  2. 11.x core/tests/Drupal/Tests/Core/Test/WebAssertTest.php \Drupal\Tests\Core\Test\WebAssertTest::testPageContainsNoDuplicateId()

Tests pageContainsNoDuplicateId() functionality.

@covers ::pageContainsNoDuplicateId

File

core/tests/Drupal/Tests/Core/Test/WebAssertTest.php, line 401

Class

WebAssertTest
Tests WebAssert functionality.

Namespace

Drupal\Tests\Core\Test

Code

public function testPageContainsNoDuplicateId() : void {
    $this->visit('', <<<HTML
      <h1 id="page-element-title">Hello</h1>
      <h2 id="page-element-description">World</h2>
HTML
);
    $assert_session = $this->assertSession();
    $assert_session->pageContainsNoDuplicateId();
    $this->visit('', <<<HTML
      <h1 id="page-element">Hello</h1>
      <h2 id="page-element">World</h2>
HTML
);
    $this->expectException(ExpectationException::class);
    $this->expectExceptionMessage('The page contains a duplicate HTML ID "page-element".');
    $assert_session->pageContainsNoDuplicateId();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.