function UpdateRegistryTest::testGetPendingCustomUpdateFunctions
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Update/UpdateRegistryTest.php \Drupal\Tests\Core\Update\UpdateRegistryTest::testGetPendingCustomUpdateFunctions()
@covers ::getPendingUpdateFunctions
File
-
core/
tests/ Drupal/ Tests/ Core/ Update/ UpdateRegistryTest.php, line 627
Class
- UpdateRegistryTest
- @coversDefaultClass \Drupal\Core\Update\UpdateRegistry @group Update
Namespace
Drupal\Tests\Core\UpdateCode
public function testGetPendingCustomUpdateFunctions() : void {
// Set up a simplified module structure with custom update hooks.
$info_a = <<<'EOS'
type: module
name: Module A
core_version_requirement: '*'
EOS;
$info_d = <<<'EOS'
type: theme
name: Theme D
EOS;
$module_a = <<<'EOS'
<?php
/**
* Module A update A.
*/
function module_a_custom_update_a() {
}
EOS;
$theme_d = <<<'EOS'
<?php
/**
* Theme D update B.
*/
function theme_d_custom_update_a() {
}
EOS;
vfsStream::setup('drupal');
vfsStream::create([
'sites' => [
'default' => [
'modules' => [
'module_a' => [
'module_a.custom_update.php' => $module_a,
'module_a.info.yml' => $info_a,
],
],
'themes' => [
'theme_d' => [
'theme_d.custom_update.php' => $theme_d,
'theme_d.info.yml' => $info_d,
],
],
],
],
]);
$key_value = $this->prophesize(KeyValueStoreInterface::class);
$key_value->get('existing_updates', [])
->willReturn([]);
$key_value = $key_value->reveal();
$theme_handler = $this->prophesize(ThemeHandlerInterface::class);
$theme_handler->listInfo()
->willReturn([
'theme_d' => [
'type' => 'theme_d',
'pathname' => 'core/themes/theme_d/theme_d.info.yml',
],
]);
$theme_handler = $theme_handler->reveal();
$update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
'module_a' => [
'type' => 'module',
'pathname' => 'core/modules/module_a/module_a.info.yml',
'filename' => 'module_a.module',
],
], $key_value, $theme_handler, 'custom_update');
// Themes are not supported.
$this->assertEquals([
'module_a_custom_update_a',
], $update_registry->getPendingUpdateFunctions());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.