function UpdateSemverCoreSecurityCoverageTest::doTestSecurityCoverageMessage

Same name in other branches
  1. 10 core/modules/update/tests/src/Functional/UpdateSemverCoreSecurityCoverageTest.php \Drupal\Tests\update\Functional\UpdateSemverCoreSecurityCoverageTest::doTestSecurityCoverageMessage()

Tests the security coverage messages for Drupal core versions.

Parameters

string $installed_version: The installed Drupal version to test.

string $fixture: The test fixture that contains the test XML.

string $requirements_section_heading: The requirements section heading.

string $message: The expected coverage message.

string $mock_date: The mock date to use if needed in the format CCYY-MM-DD. If an empty string is provided, no mock date will be used.

1 call to UpdateSemverCoreSecurityCoverageTest::doTestSecurityCoverageMessage()
UpdateSemverCoreSecurityCoverageTest::testSecurityCoverageMessage in core/modules/update/tests/src/Functional/UpdateSemverCoreSecurityCoverageTest.php
Tests the security coverage messages for Drupal core versions.

File

core/modules/update/tests/src/Functional/UpdateSemverCoreSecurityCoverageTest.php, line 38

Class

UpdateSemverCoreSecurityCoverageTest
Tests the security coverage messages for Drupal core versions.

Namespace

Drupal\Tests\update\Functional

Code

protected function doTestSecurityCoverageMessage($installed_version, $fixture, $requirements_section_heading, $message, $mock_date) : void {
    \Drupal::state()->set('update_test.mock_date', $mock_date);
    $this->setProjectInstalledVersion($installed_version);
    $this->refreshUpdateStatus([
        'drupal' => $fixture,
    ]);
    $this->drupalGet('admin/reports/status');
    if (empty($requirements_section_heading)) {
        $this->assertSession()
            ->pageTextNotContains('Drupal core security coverage');
        return;
    }
    $all_requirements_details = $this->getSession()
        ->getPage()
        ->findAll('css', 'details.system-status-report__entry:contains("Drupal core security coverage")');
    // Ensure we only have 1 security message section.
    $this->assertCount(1, $all_requirements_details);
    $requirements_details = $all_requirements_details[0];
    // Ensure that messages are under the correct heading which could be
    // 'Checked', 'Warnings found', or 'Errors found'.
    $requirements_section_element = $requirements_details->getParent();
    $this->assertCount(1, $requirements_section_element->findAll('css', "h3:contains('{$requirements_section_heading}')"));
    $actual_message = $requirements_details->find('css', 'div.system-status-report__entry__value')
        ->getText();
    $this->assertNotEmpty($actual_message);
    $this->assertEquals($message, $actual_message);
}

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