function StatusTest::testErrorElementCount

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/System/StatusTest.php \Drupal\Tests\system\Functional\System\StatusTest::testErrorElementCount()

Tests that the Error counter matches the displayed number of errors.

File

core/modules/system/tests/src/Functional/System/StatusTest.php, line 209

Class

StatusTest
Tests output on the status overview page.

Namespace

Drupal\Tests\system\Functional\System

Code

public function testErrorElementCount() : void {
    // Trigger "cron has not run recently" error:
    $cron_config = \Drupal::config('system.cron');
    $time = \Drupal::time()->getRequestTime();
    \Drupal::state()->set('install_time', $time);
    $threshold_error = $cron_config->get('threshold.requirements_error');
    \Drupal::state()->set('system.cron_last', $time - $threshold_error - 1);
    $this->drupalGet('admin/reports/status');
    $error_elements = $this->cssSelect('.system-status-report__status-icon--error');
    $this->assertNotEquals(count($error_elements), 0, 'Errors are listed on the page.');
    $expected_text = new PluralTranslatableMarkup(count($error_elements), 'Error', 'Errors');
    $expected_text = count($error_elements) . ' ' . $expected_text;
    $this->assertSession()
        ->responseContains((string) $expected_text);
}

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