function StatusReportPageTest::testPeRenderCounters

Tests the status report page element.

File

core/modules/system/tests/src/Kernel/Element/StatusReportPageTest.php, line 24

Class

StatusReportPageTest
Tests the status report page element.

Namespace

Drupal\Tests\system\Kernel\Element

Code

public function testPeRenderCounters() : void {
  $element = [
    '#requirements' => [
      'foo' => [
        'title' => 'Foo',
        'severity' => \REQUIREMENT_INFO,
      ],
      'baz' => [
        'title' => 'Baz',
        'severity' => RequirementSeverity::Warning,
      ],
      'wiz' => [
        'title' => 'Wiz',
        'severity' => RequirementSeverity::Error,
      ],
    ],
  ];
  $this->expectDeprecation('Calling Drupal\\system\\Element\\StatusReportPage::preRenderCounters() with an array of $requirements with \'severity\' with values not of type Drupal\\Core\\Extension\\Requirement\\RequirementSeverity enums is deprecated in drupal:11.2.0 and is required in drupal:12.0.0. See https://www.drupal.org/node/3410939');
  $element = StatusReportPage::preRenderCounters($element);
  $error = $element['#counters']['error'];
  $this->assertEquals(1, $error['#amount']);
  $this->assertEquals('error', $error['#severity']);
  $warning = $element['#counters']['warning'];
  $this->assertEquals(1, $warning['#amount']);
  $this->assertEquals('warning', $warning['#severity']);
  $checked = $element['#counters']['checked'];
  $this->assertEquals(1, $checked['#amount']);
  $this->assertEquals('checked', $checked['#severity']);
}

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