public function ReadinessValidationManagerTest::testGetResults in Automatic Updates 8.2
@covers ::getResults
File
- tests/
src/ Kernel/ ReadinessValidation/ ReadinessValidationManagerTest.php, line 39
Class
- ReadinessValidationManagerTest
- @coversDefaultClass \Drupal\automatic_updates\Validation\ReadinessValidationManager
Namespace
Drupal\Tests\automatic_updates\Kernel\ReadinessValidationCode
public function testGetResults() : void {
$this
->enableModules([
'automatic_updates',
'automatic_updates_test2',
]);
$this
->assertCheckerResultsFromManager([], TRUE);
$expected_results = [
array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']),
];
TestChecker1::setTestResult($expected_results[0]);
TestChecker2::setTestResult($expected_results[1]);
$expected_results_all = array_merge($expected_results[0], $expected_results[1]);
$this
->assertCheckerResultsFromManager($expected_results_all, TRUE);
// Define a constant flag that will cause the readiness checker
// service priority to be altered.
// @see \Drupal\automatic_updates_test\AutoUpdatesTestServiceProvider::alter().
define('AUTOMATIC_UPDATES_TEST_SET_PRIORITY', 1);
// Rebuild the container to trigger the service to be altered.
$kernel = $this->container
->get('kernel');
$this->container = $kernel
->rebuildContainer();
// Confirm that results will be NULL if the run() is not called again
// because the readiness checker services order has been altered.
$this
->assertNull($this
->getResultsFromManager());
// Confirm that after calling run() the expected results order has changed.
$expected_results_all_reversed = array_reverse($expected_results_all);
$this
->assertCheckerResultsFromManager($expected_results_all_reversed, TRUE);
$expected_results = [
$this->testResults['checker_1']['2 errors 2 warnings'],
$this->testResults['checker_2']['2 errors 2 warnings'],
];
TestChecker1::setTestResult($expected_results[0]);
TestChecker2::setTestResult($expected_results[1]);
$expected_results_all = array_merge($expected_results[1], $expected_results[0]);
$this
->assertCheckerResultsFromManager($expected_results_all, TRUE);
// Confirm that filtering by severity works.
$warnings_only_results = [
$expected_results[1]['2:warnings'],
$expected_results[0]['1:warnings'],
];
$this
->assertCheckerResultsFromManager($warnings_only_results, FALSE, SystemManager::REQUIREMENT_WARNING);
$errors_only_results = [
$expected_results[1]['2:errors'],
$expected_results[0]['1:errors'],
];
$this
->assertCheckerResultsFromManager($errors_only_results, FALSE, SystemManager::REQUIREMENT_ERROR);
}