class PendingUpdatesValidatorTest
@covers \Drupal\package_manager\Validator\PendingUpdatesValidator @group package_manager @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\PendingUpdatesValidatorTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of PendingUpdatesValidatorTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PendingUpdatesValidatorTest.php, line 16
Namespace
Drupal\Tests\package_manager\KernelView source
class PendingUpdatesValidatorTest extends PackageManagerKernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
];
/**
* Tests that no error is raised if there are no pending updates.
*/
public function testNoPendingUpdates() : void {
$this->assertStatusCheckResults([]);
$this->assertResults([], PreCreateEvent::class);
}
/**
* Tests that an error is raised if there are pending schema updates.
*
* @depends testNoPendingUpdates
*/
public function testPendingUpdateHook() : void {
// Set the installed schema version of Package Manager to its default value
// and import an empty update hook which is numbered much higher than will
// ever exist in the real world.
$this->container
->get('keyvalue')
->get('system.schema')
->set('package_manager', \Drupal::CORE_MINIMUM_SCHEMA_VERSION);
require_once __DIR__ . '/../../fixtures/db_update.php';
$result = ValidationResult::createError([
t('Some modules have database updates pending. You should run the <a href="/update.php">database update script</a> immediately.'),
]);
$this->assertStatusCheckResults([
$result,
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
}
/**
* Tests that an error is raised if there are pending post-updates.
*/
public function testPendingPostUpdate() : void {
// Make an additional post-update function available; the update registry
// will think it's pending.
require_once __DIR__ . '/../../fixtures/post_update.php';
$result = ValidationResult::createError([
t('Some modules have database updates pending. You should run the <a href="/update.php">database update script</a> immediately.'),
]);
$this->assertStatusCheckResults([
$result,
]);
$this->assertResults([
$result,
], PreCreateEvent::class);
}
/**
* Tests that pending updates stop an operation from being applied.
*/
public function testPendingUpdateAfterStaged() : void {
$stage = $this->createStage();
$stage->create();
$stage->require([
'drupal/core:9.8.1',
]);
// Make an additional post-update function available; the update registry
// will think it's pending.
require_once __DIR__ . '/../../fixtures/post_update.php';
$result = ValidationResult::createError([
t('Some modules have database updates pending. You should run the <a href="/update.php">database update script</a> immediately.'),
]);
try {
$stage->apply();
$this->fail('Able to apply update even though there is pending update.');
} catch (StageEventException $exception) {
$this->assertExpectedResultsFromException([
$result,
], $exception);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.