LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php in Zircon Profile 8.0
File
core/modules/system/src/Tests/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php
View source
<?php
namespace Drupal\system\Tests\Update;
use Drupal\node\Entity\Node;
class LocalActionsAndTasksConvertedIntoBlocksUpdateTest extends UpdatePathTestBase {
public function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.local-actions-tasks-into-blocks-507488.php',
];
}
public function setUp() {
parent::setUp();
$theme_handler = \Drupal::service('theme_handler');
$theme_handler
->refreshInfo();
}
public function testUpdateHookN() {
$this
->runUpdates();
$block_storage = \Drupal::entityManager()
->getStorage('block');
$help_blocks = $block_storage
->loadByProperties([
'theme' => 'bartik',
'region' => 'help',
]);
$this
->assertRaw('Because your site has custom theme(s) installed, we had to set local actions and tasks blocks into the content region. Please manually review the block configurations and remove the removed variables from your templates.');
\Drupal::state()
->set('system.maintenance_mode', FALSE);
$this
->drupalLogin($this->rootUser);
$page = Node::create([
'type' => 'page',
'title' => 'Page node',
]);
$page
->save();
foreach ($help_blocks as $block) {
$new_block = $block_storage
->load($block
->id());
$this
->assertEqual($new_block
->getRegion(), 'content');
}
$this
->drupalGet('node/' . $page
->id());
$this
->assertText(t('Edit'));
$this
->drupalGet('admin/content');
$action_link = $this
->cssSelect('.action-links');
$this
->assertTrue($action_link);
$this
->drupalGet('admin/structure/block/list/seven');
$config_storage = \Drupal::service('config.storage');
$this
->assertTrue($config_storage
->exists('block.block.test_theme_local_tasks'), 'Local task block has been created for the custom theme.');
$this
->assertTrue($config_storage
->exists('block.block.test_theme_local_actions'), 'Local action block has been created for the custom theme.');
}
}