You are here

public function BrowserTestBaseTest::testPageContainsNoDuplicateId in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testPageContainsNoDuplicateId()

Tests pageContainsNoDuplicateId() functionality.

See also

\Drupal\Tests\WebAssert::pageContainsNoDuplicateId()

File

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

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();
}