You are here

public function BrowserTestBaseTest::testPageContainsNoDuplicateId in Drupal 9

Tests pageContainsNoDuplicateId() functionality.

See also

\Drupal\Tests\WebAssert::pageContainsNoDuplicateId()

File

core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php, line 841

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\FunctionalTests

Code

public function testPageContainsNoDuplicateId() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet(Url::fromRoute('test_page_test.page_without_duplicate_ids'));
  $assert_session
    ->pageContainsNoDuplicateId();
  $this
    ->drupalGet(Url::fromRoute('test_page_test.page_with_duplicate_ids'));
  $this
    ->expectException(ExpectationException::class);
  $this
    ->expectExceptionMessage('The page contains a duplicate HTML ID "page-element".');
  $assert_session
    ->pageContainsNoDuplicateId();
}