Loading core/includes/install.core.inc +19 −0 Changes for core/includes/install.core.inc: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1582,6 +1582,13 @@ function install_profile_modules(&$install_state) { install_core_entity_type_definitions(); $modules = $install_state['profile_info']['install']; // Extra module support is only implemented by the testing framework, to // reduce the number of container rebuilds during test runs. $extra_modules = $install_state['extra_modules'] ?? []; if ($extra_modules) { $modules = array_merge($modules, $extra_modules); } $files = \Drupal::service('extension.list.module')->getList(); // Always install required modules first. Respect the dependencies between Loading Loading @@ -1682,6 +1689,12 @@ function install_core_entity_type_definitions(): void { function install_profile_themes(&$install_state): void { // Install the themes specified by the installation profile. $themes = $install_state['profile_info']['themes']; // Default theme support is only implemented by the testing framework, to // reduce the number of container rebuilds during test runs. if (isset($install_state['default_theme'])) { $themes = array_unique(array_merge($themes, [$install_state['default_theme']])); } \Drupal::service('theme_installer')->install($themes); // Ensure that the install profile's theme is used. Loading Loading @@ -1709,6 +1722,12 @@ function install_install_profile(&$install_state): void { \Drupal::service('module_installer')->install([$install_state['parameters']['profile']], FALSE); } if (isset($install_state['default_theme'])) { \Drupal::service('config.factory')->getEditable('system.theme') ->set('default', $install_state['default_theme']) ->save(); } // Ensure that the install profile's theme is used. // @see _drupal_maintenance_theme() \Drupal::theme()->resetActiveTheme(); Loading core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +32 −10 Changes for core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php: 32 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -489,6 +489,27 @@ protected function installDefaultThemeFromClassProperty(ContainerInterface $cont } } /** * Gets a list of modules recursively from inherited class properties. * * @return array * The modules to install, or an empty array if none are specified. */ protected function getModulesFromClassProperty(): array { $class = static::class; $modules = []; while ($class) { if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); } $class = get_parent_class($class); } if ($modules) { $modules = array_unique($modules); } return $modules; } /** * Install modules defined by `static::$modules`. * Loading @@ -500,18 +521,15 @@ protected function installDefaultThemeFromClassProperty(ContainerInterface $cont * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The container. * * @deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. There is no * replacement. * @see https://www.drupal.org/node/3616201 */ protected function installModulesFromClassProperty(ContainerInterface $container) { $class = static::class; $modules = []; while ($class) { if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); } $class = get_parent_class($class); } trigger_error(__METHOD__ . 'is deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3616201', E_USER_DEPRECATED); $modules = $this->getModulesFromClassProperty(); if ($modules) { $modules = array_unique($modules); try { $success = $container->get('module_installer')->install($modules, TRUE); $this->assertTrue($success, 'Enabled modules: ' . implode(', ', $modules)); Loading Loading @@ -550,7 +568,7 @@ protected function installParameters(): array { $formInput = Database::getConnectionInfo()['default']; $driverName = $formInput['driver']; $driverNamespace = $formInput['namespace']; $modules = $this->getModulesFromClassProperty(); unset($formInput['driver']); unset($formInput['namespace']); unset($formInput['autoload']); Loading @@ -571,6 +589,7 @@ protected function installParameters(): array { 'profile' => $this->profile, 'langcode' => 'en', ], 'extra_modules' => $modules, 'forms' => [ 'install_settings_form' => [ 'driver' => $driverNamespace, Loading @@ -595,6 +614,9 @@ protected function installParameters(): array { ], ], ]; if (isset($this->defaultTheme)) { $parameters['default_theme'] = $this->defaultTheme; } // If we only have one db driver available, we cannot set the driver. if (count(Database::getDriverList()->getInstallableList()) == 1) { Loading core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml→core/modules/block/tests/modules/block_test/config/optional/block.block.test_block.yml +0 −0 File moved. View file core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +9 −8 Changes for core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php: 9 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ protected function setUp(): void { parent::setUp(); $this->controller = $this->container->get('entity_type.manager')->getStorage('block'); $this->container->get('theme_installer')->install(['stark']); } /** Loading @@ -50,6 +48,7 @@ public function testBlockCRUD(): void { $this->assertInstanceOf(ConfigEntityStorage::class, $this->controller); // Run each test method in the same installation. \Drupal::service('theme_installer')->install(['stark']); $this->createTests(); $this->loadTests(); $this->deleteTests(); Loading @@ -71,7 +70,7 @@ protected function createTests(): void { // Create a block with only required values. $entity = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'region' => 'content', 'plugin' => 'test_html', Loading @@ -81,7 +80,7 @@ protected function createTests(): void { $this->assertInstanceOf(Block::class, $entity); // Verify all of the block properties. $actual_properties = $this->config('block.block.test_block')->get(); $actual_properties = $this->config('block.block.test_block_0')->get(); $this->assertNotEmpty($actual_properties['uuid'], 'The block UUID is set.'); unset($actual_properties['uuid']); Loading @@ -90,7 +89,7 @@ protected function createTests(): void { 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, 'dependencies' => ['module' => ['block_test'], 'theme' => ['stark']], 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'region' => 'content', 'weight' => 0, Loading @@ -114,7 +113,7 @@ protected function createTests(): void { * Tests the loading of blocks. */ protected function loadTests(): void { $entity = $this->controller->load('test_block'); $entity = $this->controller->load('test_block_0'); $this->assertInstanceOf(Block::class, $entity); Loading @@ -129,7 +128,7 @@ protected function loadTests(): void { * Tests the deleting of blocks. */ protected function deleteTests(): void { $entity = $this->controller->load('test_block'); $entity = $this->controller->load('test_block_0'); // Ensure that the storage isn't currently empty. $config_storage = $this->container->get('config.storage'); Loading @@ -138,6 +137,8 @@ protected function deleteTests(): void { // Delete the block. $entity->delete(); $entity = $this->controller->load('test_block'); $entity->delete(); // Ensure that the storage is now empty. $config = $config_storage->listAll('block.block.'); Loading @@ -148,9 +149,9 @@ protected function deleteTests(): void { * Tests the installation of default blocks. */ public function testDefaultBlocks(): void { \Drupal::service('theme_installer')->install(['stark']); $entities = $this->controller->loadMultiple(); $this->assertEmpty($entities, 'There are no blocks initially.'); \Drupal::service('theme_installer')->install(['stark']); // Install the block_test.module, so that its default config is installed. $this->installConfig(['block_test']); Loading core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php +6 −6 Changes for core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ protected function setUp(): void { // Create a block with only required values. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache', ]); Loading Loading @@ -185,7 +185,7 @@ public function testBlockViewBuilderCache(): void { // Create an empty block. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache', ]); Loading Loading @@ -237,7 +237,7 @@ protected function verifyRenderCacheHandling(): void { // Test that a cache entry is created. $build = $this->getBlockRenderArray(); $cache_keys = ['entity_view', 'block', 'test_block']; $cache_keys = ['entity_view', 'block', 'test_block_0']; $this->renderer->renderRoot($build); $this->assertNotEmpty($cache_bin->get($cache_keys, CacheableMetadata::createFromRenderArray($build)), 'The block render element has been cached.'); Loading Loading @@ -270,7 +270,7 @@ public function testBlockViewBuilderCacheOptional(): void { // Create a block with a plugin implementing CacheOptionalInterface. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache_optional', ]); Loading @@ -288,7 +288,7 @@ public function testBlockViewBuilderCacheOptional(): void { // Test that an entry for the block is not created in the render cache. $build = $this->getBlockRenderArray(); $cache_keys = ['entity_view', 'block', 'test_block']; $cache_keys = ['entity_view', 'block', 'test_block_0']; $markup = $this->renderer->renderRoot($build); $this->assertTrue(str_contains((string) $markup, 'This is content for a block that is not render cached.')); $this->assertFalse($cache_bin->get($cache_keys, CacheableMetadata::createFromRenderArray($build))); Loading Loading @@ -344,7 +344,7 @@ public function testBlockViewBuilderBuildAlter(): void { $request_method = $request->server->get('REQUEST_METHOD'); $request->setMethod('GET'); $default_keys = ['entity_view', 'block', 'test_block']; $default_keys = ['entity_view', 'block', 'test_block_0']; $default_contexts = []; $default_tags = ['config:block_list']; $default_max_age = Cache::PERMANENT; Loading Loading
core/includes/install.core.inc +19 −0 Changes for core/includes/install.core.inc: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1582,6 +1582,13 @@ function install_profile_modules(&$install_state) { install_core_entity_type_definitions(); $modules = $install_state['profile_info']['install']; // Extra module support is only implemented by the testing framework, to // reduce the number of container rebuilds during test runs. $extra_modules = $install_state['extra_modules'] ?? []; if ($extra_modules) { $modules = array_merge($modules, $extra_modules); } $files = \Drupal::service('extension.list.module')->getList(); // Always install required modules first. Respect the dependencies between Loading Loading @@ -1682,6 +1689,12 @@ function install_core_entity_type_definitions(): void { function install_profile_themes(&$install_state): void { // Install the themes specified by the installation profile. $themes = $install_state['profile_info']['themes']; // Default theme support is only implemented by the testing framework, to // reduce the number of container rebuilds during test runs. if (isset($install_state['default_theme'])) { $themes = array_unique(array_merge($themes, [$install_state['default_theme']])); } \Drupal::service('theme_installer')->install($themes); // Ensure that the install profile's theme is used. Loading Loading @@ -1709,6 +1722,12 @@ function install_install_profile(&$install_state): void { \Drupal::service('module_installer')->install([$install_state['parameters']['profile']], FALSE); } if (isset($install_state['default_theme'])) { \Drupal::service('config.factory')->getEditable('system.theme') ->set('default', $install_state['default_theme']) ->save(); } // Ensure that the install profile's theme is used. // @see _drupal_maintenance_theme() \Drupal::theme()->resetActiveTheme(); Loading
core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +32 −10 Changes for core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php: 32 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -489,6 +489,27 @@ protected function installDefaultThemeFromClassProperty(ContainerInterface $cont } } /** * Gets a list of modules recursively from inherited class properties. * * @return array * The modules to install, or an empty array if none are specified. */ protected function getModulesFromClassProperty(): array { $class = static::class; $modules = []; while ($class) { if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); } $class = get_parent_class($class); } if ($modules) { $modules = array_unique($modules); } return $modules; } /** * Install modules defined by `static::$modules`. * Loading @@ -500,18 +521,15 @@ protected function installDefaultThemeFromClassProperty(ContainerInterface $cont * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container * The container. * * @deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. There is no * replacement. * @see https://www.drupal.org/node/3616201 */ protected function installModulesFromClassProperty(ContainerInterface $container) { $class = static::class; $modules = []; while ($class) { if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); } $class = get_parent_class($class); } trigger_error(__METHOD__ . 'is deprecated in drupal:12.0.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3616201', E_USER_DEPRECATED); $modules = $this->getModulesFromClassProperty(); if ($modules) { $modules = array_unique($modules); try { $success = $container->get('module_installer')->install($modules, TRUE); $this->assertTrue($success, 'Enabled modules: ' . implode(', ', $modules)); Loading Loading @@ -550,7 +568,7 @@ protected function installParameters(): array { $formInput = Database::getConnectionInfo()['default']; $driverName = $formInput['driver']; $driverNamespace = $formInput['namespace']; $modules = $this->getModulesFromClassProperty(); unset($formInput['driver']); unset($formInput['namespace']); unset($formInput['autoload']); Loading @@ -571,6 +589,7 @@ protected function installParameters(): array { 'profile' => $this->profile, 'langcode' => 'en', ], 'extra_modules' => $modules, 'forms' => [ 'install_settings_form' => [ 'driver' => $driverNamespace, Loading @@ -595,6 +614,9 @@ protected function installParameters(): array { ], ], ]; if (isset($this->defaultTheme)) { $parameters['default_theme'] = $this->defaultTheme; } // If we only have one db driver available, we cannot set the driver. if (count(Database::getDriverList()->getInstallableList()) == 1) { Loading
core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml→core/modules/block/tests/modules/block_test/config/optional/block.block.test_block.yml +0 −0 File moved. View file
core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +9 −8 Changes for core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php: 9 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ protected function setUp(): void { parent::setUp(); $this->controller = $this->container->get('entity_type.manager')->getStorage('block'); $this->container->get('theme_installer')->install(['stark']); } /** Loading @@ -50,6 +48,7 @@ public function testBlockCRUD(): void { $this->assertInstanceOf(ConfigEntityStorage::class, $this->controller); // Run each test method in the same installation. \Drupal::service('theme_installer')->install(['stark']); $this->createTests(); $this->loadTests(); $this->deleteTests(); Loading @@ -71,7 +70,7 @@ protected function createTests(): void { // Create a block with only required values. $entity = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'region' => 'content', 'plugin' => 'test_html', Loading @@ -81,7 +80,7 @@ protected function createTests(): void { $this->assertInstanceOf(Block::class, $entity); // Verify all of the block properties. $actual_properties = $this->config('block.block.test_block')->get(); $actual_properties = $this->config('block.block.test_block_0')->get(); $this->assertNotEmpty($actual_properties['uuid'], 'The block UUID is set.'); unset($actual_properties['uuid']); Loading @@ -90,7 +89,7 @@ protected function createTests(): void { 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, 'dependencies' => ['module' => ['block_test'], 'theme' => ['stark']], 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'region' => 'content', 'weight' => 0, Loading @@ -114,7 +113,7 @@ protected function createTests(): void { * Tests the loading of blocks. */ protected function loadTests(): void { $entity = $this->controller->load('test_block'); $entity = $this->controller->load('test_block_0'); $this->assertInstanceOf(Block::class, $entity); Loading @@ -129,7 +128,7 @@ protected function loadTests(): void { * Tests the deleting of blocks. */ protected function deleteTests(): void { $entity = $this->controller->load('test_block'); $entity = $this->controller->load('test_block_0'); // Ensure that the storage isn't currently empty. $config_storage = $this->container->get('config.storage'); Loading @@ -138,6 +137,8 @@ protected function deleteTests(): void { // Delete the block. $entity->delete(); $entity = $this->controller->load('test_block'); $entity->delete(); // Ensure that the storage is now empty. $config = $config_storage->listAll('block.block.'); Loading @@ -148,9 +149,9 @@ protected function deleteTests(): void { * Tests the installation of default blocks. */ public function testDefaultBlocks(): void { \Drupal::service('theme_installer')->install(['stark']); $entities = $this->controller->loadMultiple(); $this->assertEmpty($entities, 'There are no blocks initially.'); \Drupal::service('theme_installer')->install(['stark']); // Install the block_test.module, so that its default config is installed. $this->installConfig(['block_test']); Loading
core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php +6 −6 Changes for core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ protected function setUp(): void { // Create a block with only required values. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache', ]); Loading Loading @@ -185,7 +185,7 @@ public function testBlockViewBuilderCache(): void { // Create an empty block. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache', ]); Loading Loading @@ -237,7 +237,7 @@ protected function verifyRenderCacheHandling(): void { // Test that a cache entry is created. $build = $this->getBlockRenderArray(); $cache_keys = ['entity_view', 'block', 'test_block']; $cache_keys = ['entity_view', 'block', 'test_block_0']; $this->renderer->renderRoot($build); $this->assertNotEmpty($cache_bin->get($cache_keys, CacheableMetadata::createFromRenderArray($build)), 'The block render element has been cached.'); Loading Loading @@ -270,7 +270,7 @@ public function testBlockViewBuilderCacheOptional(): void { // Create a block with a plugin implementing CacheOptionalInterface. $this->block = $this->controller->create([ 'id' => 'test_block', 'id' => 'test_block_0', 'theme' => 'stark', 'plugin' => 'test_cache_optional', ]); Loading @@ -288,7 +288,7 @@ public function testBlockViewBuilderCacheOptional(): void { // Test that an entry for the block is not created in the render cache. $build = $this->getBlockRenderArray(); $cache_keys = ['entity_view', 'block', 'test_block']; $cache_keys = ['entity_view', 'block', 'test_block_0']; $markup = $this->renderer->renderRoot($build); $this->assertTrue(str_contains((string) $markup, 'This is content for a block that is not render cached.')); $this->assertFalse($cache_bin->get($cache_keys, CacheableMetadata::createFromRenderArray($build))); Loading Loading @@ -344,7 +344,7 @@ public function testBlockViewBuilderBuildAlter(): void { $request_method = $request->server->get('REQUEST_METHOD'); $request->setMethod('GET'); $default_keys = ['entity_view', 'block', 'test_block']; $default_keys = ['entity_view', 'block', 'test_block_0']; $default_contexts = []; $default_tags = ['config:block_list']; $default_max_age = Cache::PERMANENT; Loading