Forked from
project / automatic_updates
821 commits behind the upstream repository.
-
Issue #3236299 by kunal.sachdev, phenaproxima, Suresh Prabhu Parkala, tedbow: User should not be allowed to do update if it is from minor version to another minor version
Issue #3236299 by kunal.sachdev, phenaproxima, Suresh Prabhu Parkala, tedbow: User should not be allowed to do update if it is from minor version to another minor version
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ReadinessValidationManagerTest.php 10.77 KiB
<?php
namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
use Drupal\automatic_updates_test2\ReadinessChecker\TestChecker2;
use Drupal\system\SystemManager;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
/**
* @coversDefaultClass \Drupal\automatic_updates\Validation\ReadinessValidationManager
*
* @group automatic_updates
*/
class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
use ValidationTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'automatic_updates_test',
'package_manager',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('user');
$this->installSchema('user', ['users_data']);
$this->createTestValidationResults();
$this->installConfig('update');
$this->setCoreVersion('9.8.0');
$this->setReleaseMetadata(__DIR__ . '/../../../fixtures/release-history/drupal.9.8.1.xml');
}
/**
* @covers ::getResults
*/
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);