diff --git a/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php b/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php new file mode 100644 index 0000000..73e681b --- /dev/null +++ b/core/modules/system/src/Tests/Update/SiteBrandingConvertedIntoBlockUpdateTest.php @@ -0,0 +1,64 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php', + ]; + parent::setUp(); + } + + /** + * Tests that site branding elements are being converted into blocks. + */ + public function testUpdateHookN() { + $this->runUpdates(); + + /** @var \Drupal\block\BlockInterface $block_storage */ + $block_storage = \Drupal::entityManager()->getStorage('block'); + + $this->assertRaw('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.'); + + // Disable maintenance mode. + // @todo Can be removed once maintenance mode is automatically turned off + // after updates in https://www.drupal.org/node/2435135. + \Drupal::state()->set('system.maintenance_mode', FALSE); + + // We finished updating so we can login the user now. + $this->drupalLogin($this->rootUser); + + // Site branding is visible on the home page. + $this->drupalGet('/'); + $this->assertRaw('site-branding__logo'); + $this->assertRaw('site-branding__name'); + $this->assertRaw('site-branding__slogan'); + + $this->drupalGet('admin/structure/block/list/bartik'); + + /** @var \Drupal\Core\Config\StorageInterface $config_storage */ + $config_storage = \Drupal::service('config.storage'); + $this->assertTrue($config_storage->exists('block.block.test_theme_branding'), 'Site branding block has been created for the custom theme.'); + } + +} diff --git a/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml b/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml new file mode 100644 index 0000000..4396c75 --- /dev/null +++ b/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml @@ -0,0 +1,25 @@ +uuid: b299258f-6fb5-47f8-b42f-473787d02e22 +langcode: en +status: true +dependencies: + module: + - system + theme: + - bartik +id: bartik_branding +theme: bartik +region: header +weight: 0 +provider: null +plugin: system_branding_block +settings: + id: system_branding_block + label: 'Site Branding' + provider: system + label_display: '0' + cache: + max_age: -1 + use_site_logo: true + use_site_name: true + use_site_slogan: true +visibility: { } diff --git a/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php new file mode 100644 index 0000000..576762d --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php @@ -0,0 +1,60 @@ +insert('config') + ->fields([ + 'collection', + 'name', + 'data', + ]) + ->values([ + 'collection' => '', + 'name' => 'block.block.' . $block_config['id'], + 'data' => serialize($block_config), + ]) + ->execute(); +} + +// Update the config entity query "index". +$existing_blocks = $connection->select('key_value') + ->fields('key_value', ['value']) + ->condition('collection', 'config.entity.key_store.block') + ->condition('name', 'theme:bartik') + ->execute() + ->fetchField(); +$existing_blocks = unserialize($existing_blocks); + +$connection->update('key_value') + ->fields([ + 'value' => serialize(array_merge($existing_blocks, ['block.block.bartik_branding'])) + ]) + ->condition('collection', 'config.entity.key_store.block') + ->condition('name', 'theme:bartik') + ->execute(); + +// Enable test theme. +$extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$connection->update('config') + ->fields([ + 'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]])) + ]) + ->condition('name', 'core.extension') + ->execute();