Issue #2569529 by mdrummond, DuaelFr: system_update_8005 does not create secondary tasks block in Seven
parent
372394ead8
commit
c018664692
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Update\SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Update;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Tests the upgrade path for converting seven secondary local tasks into a block.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2569529
|
||||
*
|
||||
* @group system
|
||||
*/
|
||||
class SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
$theme_handler->refreshInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that local actions/tasks are being converted into blocks.
|
||||
*/
|
||||
public function testUpdateHookN() {
|
||||
$this->runUpdates();
|
||||
|
||||
/** @var \Drupal\block\BlockInterface $block_storage */
|
||||
$block_storage = \Drupal::entityManager()->getStorage('block');
|
||||
|
||||
// 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);
|
||||
|
||||
// Local actions are visible on the content listing page.
|
||||
$this->drupalGet('admin/structure/block');
|
||||
$action_link = $this->cssSelect('#secondary-tabs-title');
|
||||
$this->assertTrue($action_link);
|
||||
}
|
||||
|
||||
}
|
|
@ -1440,6 +1440,7 @@ function system_update_8005() {
|
|||
] + $tabs_default_settings;
|
||||
_system_update_create_block($name, $theme_name, $values);
|
||||
|
||||
$name = 'block.block.seven_secondary_local_tasks';
|
||||
$values = [
|
||||
'region' => 'pre_content',
|
||||
'id' => 'seven_secondary_local_tasks',
|
||||
|
@ -1784,6 +1785,28 @@ function system_update_8010() {
|
|||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add secondary local tasks block to Seven (fixes system_update_8005).
|
||||
*/
|
||||
function system_update_8011() {
|
||||
$langcode = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
|
||||
$theme_name = 'seven';
|
||||
$name = 'block.block.seven_secondary_local_tasks';
|
||||
$values = [
|
||||
'plugin' => 'local_tasks_block',
|
||||
'region' => 'pre_content',
|
||||
'id' => 'seven_secondary_local_tasks',
|
||||
'settings.label' => 'Secondary tabs',
|
||||
'settings.label_display' => 0,
|
||||
'settings.primary' => FALSE,
|
||||
'settings.secondary' => TRUE,
|
||||
'visibility' => [],
|
||||
'weight' => 0,
|
||||
'langcode' => $langcode,
|
||||
];
|
||||
_system_update_create_block($name, $theme_name, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-8.0.0-beta".
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
theme:
|
||||
- seven
|
||||
id: seven_secondary_local_tasks
|
||||
theme: seven
|
||||
region: pre_content
|
||||
weight: 0
|
||||
provider: null
|
||||
plugin: local_tasks_block
|
||||
settings:
|
||||
id: local_tasks_block
|
||||
label: 'Secondary tabs'
|
||||
provider: core
|
||||
label_display: '0'
|
||||
primary: false
|
||||
secondary: true
|
||||
visibility: { }
|
46
core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php
vendored
Normal file
46
core/modules/system/tests/fixtures/update/drupal-8.seven-secondary-local-tasks-block-2569529.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/507488.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a custom block with visibility settings.
|
||||
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml'));
|
||||
|
||||
foreach ($block_configs as $block_config) {
|
||||
$connection->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:seven')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$existing_blocks = unserialize($existing_blocks);
|
||||
|
||||
$connection->update('key_value')
|
||||
->fields([
|
||||
'value' => serialize(array_merge($existing_blocks, ['block.block.seven_secondary_local_tasks']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:seven')
|
||||
->execute();
|
Loading…
Reference in New Issue