function UpdateRequirementsTest::testUpdateRequirements
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/Core/Updater/UpdateRequirementsTest.php \Drupal\KernelTests\Core\Updater\UpdateRequirementsTest::testUpdateRequirements()
Tests hook_update_requirements().
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Updater/ UpdateRequirementsTest.php, line 26
Class
Namespace
Drupal\KernelTests\Core\UpdaterCode
public function testUpdateRequirements() : void {
\Drupal::service('module_installer')->install([
'module_update_requirements',
]);
// Installing a module rebuilds the container, so get the service after.
$databaseUpdate = \Drupal::service(DatabaseUpdate::class);
$testRequirements = [
'title' => 'UpdateError',
'value' => 'None',
'description' => 'Update Error.',
'severity' => RequirementSeverity::Error,
];
$requirements = $databaseUpdate->getRequirements()['test.update.error'];
$this->assertEquals($testRequirements, $requirements);
$testAlterRequirements = [
'title' => 'UpdateWarning',
'value' => 'None',
'description' => 'Update Warning.',
'severity' => RequirementSeverity::Warning,
];
$alterRequirements = $databaseUpdate->getRequirements()['test.update.error.alter'];
$this->assertEquals($testAlterRequirements, $alterRequirements);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.