class LegacyRequirementSeverityTest
Tests the legacy requirements severity deprecations.
@coversDefaultClass \Drupal\Core\Extension\Requirement\RequirementSeverity
@group extension
@group legacy
Hierarchy
- class \Drupal\KernelTests\Core\Extension\LegacyRequirementSeverityTest
Expanded class hierarchy of LegacyRequirementSeverityTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Extension/ LegacyRequirementSeverityTest.php, line 18
Namespace
Drupal\KernelTests\Core\ExtensionView source
class LegacyRequirementSeverityTest extends KernelTestBase {
/**
* @covers \drupal_requirements_severity
* @dataProvider requirementProvider
*/
public function testGetMaxSeverity(array $requirements, int $expectedSeverity) : void {
$this->expectDeprecation('drupal_requirements_severity() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use Drupal\\Core\\Extension\\Requirement\\RequirementSeverity::maxSeverityFromRequirements() instead. See https://www.drupal.org/node/3410939');
$this->expectDeprecation('Calling Drupal\\Core\\Extension\\Requirement\\RequirementSeverity::maxSeverityFromRequirements() 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');
$severity = drupal_requirements_severity($requirements);
$this->assertEquals($expectedSeverity, $severity);
}
/**
* Data provider for requirement helper test.
*
* @return array
* Test data.
*/
public static function requirementProvider() : array {
$info = [
'title' => 'Foo',
'severity' => \REQUIREMENT_INFO,
];
$warning = [
'title' => 'Baz',
'severity' => \REQUIREMENT_WARNING,
];
$error = [
'title' => 'Wiz',
'severity' => \REQUIREMENT_ERROR,
];
$ok = [
'title' => 'Bar',
'severity' => \REQUIREMENT_OK,
];
return [
'error is most severe' => [
[
$info,
$error,
$ok,
],
\REQUIREMENT_ERROR,
],
'ok is most severe' => [
[
$info,
$ok,
],
\REQUIREMENT_OK,
],
'warning is most severe' => [
[
$warning,
$info,
$ok,
],
\REQUIREMENT_WARNING,
],
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. |
LegacyRequirementSeverityTest::requirementProvider | public static | function | Data provider for requirement helper test. |
LegacyRequirementSeverityTest::testGetMaxSeverity | public | function | @covers \drupal_requirements_severity[[api-linebreak]] @dataProvider requirementProvider |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.