public function UpdateHookRegistryTest::testGetInstalledVersion in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Update/UpdateHookRegistryTest.php \Drupal\Tests\Core\Update\UpdateHookRegistryTest::testGetInstalledVersion()
@covers ::getInstalledVersion @covers ::getAllInstalledVersions @covers ::setInstalledVersion @covers ::deleteInstalledVersion
File
- core/
tests/ Drupal/ Tests/ Core/ Update/ UpdateHookRegistryTest.php, line 109
Class
- UpdateHookRegistryTest
- @coversDefaultClass \Drupal\Core\Update\UpdateHookRegistry @group Update
Namespace
Drupal\Tests\Core\UpdateCode
public function testGetInstalledVersion() {
$versions = [
'module1' => 1,
'module2' => 20,
'module3' => 3000,
];
$this->keyValueStore
->method('getAll')
->willReturnCallback(static function () use (&$versions) {
return $versions;
});
$this->keyValueStore
->method('get')
->willReturnCallback(static function ($key) use (&$versions) {
return $versions[$key];
});
$this->keyValueStore
->method('delete')
->willReturnCallback(static function ($key) use (&$versions) {
$versions[$key] = UpdateHookRegistry::SCHEMA_UNINSTALLED;
});
$this->keyValueStore
->method('set')
->willReturnCallback(static function ($key, $value) use (&$versions) {
$versions[$key] = $value;
});
$update_registry = new UpdateHookRegistry([], $this->keyValueStore);
$this
->assertSame(3000, $update_registry
->getInstalledVersion('module3'));
$update_registry
->setInstalledVersion('module3', 3001);
$this
->assertSame(3001, $update_registry
->getInstalledVersion('module3'));
$this
->assertSame($versions, $update_registry
->getAllInstalledVersions());
$update_registry
->deleteInstalledVersion('module3');
$this
->assertSame(UpdateHookRegistry::SCHEMA_UNINSTALLED, $update_registry
->getInstalledVersion('module3'));
}