You are here

private function SecurityAdvisoryTest::assertAdminPageLinks in Drupal 9

Asserts the correct links appear on an admin page.

Parameters

string[] $expected_link_texts: The expected links' text.

int $error_or_warning: Whether the links are a warning or an error. Should be one of the REQUIREMENT_* constants.

1 call to SecurityAdvisoryTest::assertAdminPageLinks()
SecurityAdvisoryTest::testPsa in core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php
Tests that a security advisory is displayed.

File

core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php, line 221

Class

SecurityAdvisoryTest
Tests of security advisories functionality.

Namespace

Drupal\Tests\system\Functional\SecurityAdvisories

Code

private function assertAdminPageLinks(array $expected_link_texts, int $error_or_warning) : void {
  $assert = $this
    ->assertSession();
  $this
    ->drupalGet(Url::fromRoute('system.admin'));
  if ($error_or_warning === REQUIREMENT_ERROR) {
    $assert
      ->pageTextContainsOnce('Error message');
    $assert
      ->pageTextNotContains('Warning message');
  }
  else {
    $assert
      ->pageTextNotContains('Error message');
    $assert
      ->pageTextContainsOnce('Warning message');
  }
  foreach ($expected_link_texts as $expected_link_text) {
    $assert
      ->linkExists($expected_link_text);
  }
}