function StatusReportTest::testPreRenderGroupRequirements
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Render/Element/StatusReportTest.php \Drupal\KernelTests\Core\Render\Element\StatusReportTest::testPreRenderGroupRequirements()
Tests the status report element.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ StatusReportTest.php, line 25
Class
- StatusReportTest
- Tests the status report element.
Namespace
Drupal\KernelTests\Core\Render\ElementCode
public function testPreRenderGroupRequirements() : void {
$element = [
'#priorities' => [
'error',
'warning',
'checked',
'ok',
],
'#requirements' => [
'foo' => [
'title' => 'Foo',
'severity' => RequirementSeverity::Info,
],
'baz' => [
'title' => 'Baz',
'severity' => RequirementSeverity::Warning,
],
'wiz' => [
'title' => 'Wiz',
'severity' => RequirementSeverity::Error,
],
'bar' => [
'title' => 'Bar',
'severity' => RequirementSeverity::OK,
],
],
];
$element = StatusReport::preRenderGroupRequirements($element);
$groups = $element['#grouped_requirements'];
$errors = $groups['error'];
$this->assertEquals('Errors found', (string) $errors['title']);
$this->assertEquals('error', $errors['type']);
$errorItems = $errors['items'];
$this->assertCount(1, $errorItems);
$this->assertArrayHasKey('wiz', $errorItems);
$warnings = $groups['warning'];
$this->assertEquals('Warnings found', (string) $warnings['title']);
$this->assertEquals('warning', $warnings['type']);
$warningItems = $warnings['items'];
$this->assertCount(1, $warningItems);
$this->assertArrayHasKey('baz', $warningItems);
$checked = $groups['checked'];
$this->assertEquals('Checked', (string) $checked['title']);
$this->assertEquals('checked', $checked['type']);
$checkedItems = $checked['items'];
$this->assertCount(2, $checkedItems);
$this->assertArrayHasKey('foo', $checkedItems);
$this->assertArrayHasKey('bar', $checkedItems);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.