function SecurityAdvisoryTest::assertAdminPageLinks

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php \Drupal\Tests\system\Functional\SecurityAdvisories\SecurityAdvisoryTest::assertAdminPageLinks()
  2. 11.x core/modules/system/tests/src/Functional/SecurityAdvisories/SecurityAdvisoryTest.php \Drupal\Tests\system\Functional\SecurityAdvisories\SecurityAdvisoryTest::assertAdminPageLinks()

Asserts the correct links appear on an admin page.

@internal

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 223

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

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