Commit e1ef487b authored by catch's avatar catch

Issue #2513534 by tim.plunkett, lokapujya, tedbow, LewisNyman, Manjit.Singh,...

Issue #2513534 by tim.plunkett, lokapujya, tedbow, LewisNyman, Manjit.Singh, alexpott, Maninders, Bojhan: Remove the 'disabled' region from Block UI
parent 73be8c49
......@@ -5,7 +5,6 @@
* Controls the visual building blocks a page is constructed with.
*/
use Drupal\block\BlockInterface;
use Drupal\Component\Utility\Html;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
......@@ -144,17 +143,14 @@ function block_rebuild() {
$blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
foreach ($blocks as $block_id => $block) {
// Disable blocks in invalid regions.
$region = $block->getRegion();
if ($region !== BlockInterface::BLOCK_REGION_NONE) {
if (!empty($region) && !isset($regions[$region]) && $block->status()) {
drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block_id, '%region' => $region]), 'warning');
$block->disable();
}
// Set region to none if not enabled.
if (!$block->status()) {
$block->setRegion(BlockInterface::BLOCK_REGION_NONE);
$block->save();
if (!isset($regions[$block->getRegion()])) {
if ($block->status()) {
drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block_id, '%region' => $block->getRegion()]), 'warning');
}
$block
->setRegion(system_default_region($theme))
->disable()
->save();
}
}
}
......
......@@ -74,6 +74,13 @@ function block_post_update_disable_blocks_with_missing_contexts() {
}
}
/**
* Disable blocks that are placed into the "disabled" region.
*/
function block_post_update_disabled_region_update() {
// An empty update will flush caches, forcing block_rebuild() to run.
}
/**
* @} End of "addtogroup updates-8.0.0-beta".
*/
......@@ -25,6 +25,22 @@ entity.block.edit_form:
requirements:
_entity_access: 'block.update'
entity.block.enable:
path: '/admin/structure/block/manage/{block}/enable'
defaults:
_controller: '\Drupal\block\Controller\BlockController::performOperation'
op: enable
requirements:
_entity_access: 'block.enable'
entity.block.disable:
path: '/admin/structure/block/manage/{block}/disable'
defaults:
_controller: '\Drupal\block\Controller\BlockController::performOperation'
op: disable
requirements:
_entity_access: 'block.disable'
block.admin_display:
path: '/admin/structure/block'
defaults:
......
......@@ -40,3 +40,7 @@ a.block-demo-backlink:hover {
.block-form .form-item-settings-admin-label label:after {
content: ':';
}
.block-disabled:not(:hover) {
background: #fcfcfa;
opacity: 0.675;
}
......@@ -188,7 +188,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#title' => $this->t('Region'),
'#description' => $this->t('Select the region where this block should be displayed.'),
'#default_value' => $region,
'#empty_value' => BlockInterface::BLOCK_REGION_NONE,
'#required' => TRUE,
'#options' => system_region_list($theme, REGIONS_VISIBLE),
'#prefix' => '<div id="edit-block-region-wrapper">',
'#suffix' => '</div>',
......
......@@ -16,6 +16,8 @@
/**
* Denotes that a block is not enabled in any region and should not be shown.
*
* @deprecated Scheduled for removal in Drupal 9.0.0.
*/
const BLOCK_REGION_NONE = -1;
......
......@@ -156,6 +156,7 @@ protected function buildBlocksForm() {
'weight' => $entity->getWeight(),
'entity' => $entity,
'category' => $definition['category'],
'status' => $entity->status(),
);
}
......@@ -186,8 +187,7 @@ protected function buildBlocksForm() {
// Loop over each region and build blocks.
$regions = $this->systemRegionList($this->getThemeName(), REGIONS_VISIBLE);
$block_regions_with_disabled = $regions + array(BlockInterface::BLOCK_REGION_NONE => $this->t('Disabled', array(), array('context' => 'Plural')));
foreach ($block_regions_with_disabled as $region => $title) {
foreach ($regions as $region => $title) {
$form['#tabledrag'][] = array(
'action' => 'match',
'relationship' => 'sibling',
......@@ -214,9 +214,9 @@ protected function buildBlocksForm() {
'#attributes' => array('class' => 'region-title__action'),
)
),
'#prefix' => $region != BlockInterface::BLOCK_REGION_NONE ? $title : $block_regions_with_disabled[$region],
'#prefix' => $title,
'#type' => 'link',
'#title' => $this->t('Place block <span class="visually-hidden">in the %region region</span>', ['%region' => $block_regions_with_disabled[$region]]),
'#title' => $this->t('Place block <span class="visually-hidden">in the %region region</span>', ['%region' => $title]),
'#url' => Url::fromRoute('block.admin_library', ['theme' => $this->getThemeName()], ['query' => ['region' => $region]]),
'#wrapper_attributes' => array(
'colspan' => 5,
......@@ -255,12 +255,13 @@ protected function buildBlocksForm() {
'class' => array('draggable'),
),
);
$form[$entity_id]['#attributes']['class'][] = $info['status'] ? 'block-enabled' : 'block-disabled';
if ($placement && $placement == Html::getClass($entity_id)) {
$form[$entity_id]['#attributes']['class'][] = 'color-success';
$form[$entity_id]['#attributes']['class'][] = 'js-block-placed';
}
$form[$entity_id]['info'] = array(
'#plain_text' => $info['label'],
'#plain_text' => $info['status'] ? $info['label'] : $this->t('@label (disabled)', ['@label' => $info['label']]),
'#wrapper_attributes' => array(
'class' => array('block'),
),
......@@ -271,7 +272,7 @@ protected function buildBlocksForm() {
$form[$entity_id]['region-theme']['region'] = array(
'#type' => 'select',
'#default_value' => $region,
'#empty_value' => BlockInterface::BLOCK_REGION_NONE,
'#required' => TRUE,
'#title' => $this->t('Region for @block block', array('@block' => $info['label'])),
'#title_display' => 'invisible',
'#options' => $regions,
......@@ -361,12 +362,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$entity_values = $form_state->getValue(array('blocks', $entity_id));
$entity->setWeight($entity_values['weight']);
$entity->setRegion($entity_values['region']);
if ($entity->getRegion() == BlockInterface::BLOCK_REGION_NONE) {
$entity->disable();
}
else {
$entity->enable();
}
$entity->save();
}
drupal_set_message(t('The block settings have been updated.'));
......
......@@ -3,6 +3,7 @@
namespace Drupal\block\Controller;
use Drupal\Component\Utility\Html;
use Drupal\block\BlockInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -39,6 +40,23 @@ public static function create(ContainerInterface $container) {
);
}
/**
* Calls a method on a block and reloads the listing page.
*
* @param \Drupal\block\BlockInterface $block
* The block being acted upon.
* @param string $op
* The operation to perform, e.g., 'enable' or 'disable'.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* A redirect back to the listing page.
*/
public function performOperation(BlockInterface $block, $op) {
$block->$op()->save();
drupal_set_message($this->t('The block settings have been updated.'));
return $this->redirect('block.admin_display');
}
/**
* Returns a block theme demo page.
*
......
......@@ -28,11 +28,14 @@
* },
* admin_permission = "administer blocks",
* entity_keys = {
* "id" = "id"
* "id" = "id",
* "status" = "status"
* },
* links = {
* "delete-form" = "/admin/structure/block/manage/{block}/delete",
* "edit-form" = "/admin/structure/block/manage/{block}"
* "edit-form" = "/admin/structure/block/manage/{block}",
* "enable" = "/admin/structure/block/manage/{block}/enable",
* "disable" = "/admin/structure/block/manage/{block}/disable",
* },
* config_export = {
* "id",
......@@ -70,7 +73,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin
*
* @var string
*/
protected $region = self::BLOCK_REGION_NONE;
protected $region;
/**
* The block weight.
......@@ -209,13 +212,13 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
if ($status !== 0) {
return $status;
}
// Sort by weight, unless disabled.
if ($a->getRegion() != static::BLOCK_REGION_NONE) {
$weight = $a->getWeight() - $b->getWeight();
if ($weight) {
return $weight;
}
// Sort by weight.
$weight = $a->getWeight() - $b->getWeight();
if ($weight) {
return $weight;
}
// Sort by label.
return strcmp($a->label(), $b->label());
}
......@@ -327,4 +330,21 @@ public function createDuplicateBlock($new_id = NULL, $new_theme = NULL) {
return $duplicate;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
// Ensure the region is valid to mirror the behavior of block_rebuild().
// This is done primarily for backwards compatibility support of
// \Drupal\block\BlockInterface::BLOCK_REGION_NONE.
$regions = system_region_list($this->theme);
if (!isset($regions[$this->region]) && $this->status()) {
$this
->setRegion(system_default_region($this->theme))
->disable();
}
}
}
......@@ -37,8 +37,8 @@ protected function setUp() {
function testBlockInInvalidRegion() {
// Enable a test block and place it in an invalid region.
$block = $this->drupalPlaceBlock('test_html');
$block->setRegion('invalid_region');
$block->save();
\Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
$block = Block::load($block->id());
$warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block->id(), '%region' => 'invalid_region'));
......@@ -51,9 +51,8 @@ function testBlockInInvalidRegion() {
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
// Place disabled test block in the invalid region of the default theme.
\Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save();
$block = Block::load($block->id());
$block->setRegion('invalid_region');
$block->save();
// Clear the cache to check if the warning message is not triggered.
$this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
......
......@@ -178,6 +178,10 @@ function testBlock() {
// Place page title block to test error messages.
$this->drupalPlaceBlock('page_title_block');
// Disable the block.
$this->drupalGet('admin/structure/block');
$this->clickLink('Disable');
// Select the 'Powered by Drupal' block to be configured and moved.
$block = array();
$block['id'] = 'system_powered_by_block';
......@@ -199,13 +203,12 @@ function testBlock() {
$this->moveBlockToRegion($block, $region);
}
// Set the block to the disabled region.
$edit = array();
$edit['blocks[' . $block['id'] . '][region]'] = -1;
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
// Disable the block.
$this->drupalGet('admin/structure/block');
$this->clickLink('Disable');
// Confirm that the block is now listed as disabled.
$this->assertText(t('The block settings have been updated.'), 'Block successfully move to disabled region.');
$this->assertText(t('The block settings have been updated.'), 'Block successfully moved to disabled region.');
// Confirm that the block instance title and markup are not displayed.
$this->drupalGet('node');
......@@ -218,7 +221,7 @@ function testBlock() {
// Test deleting the block from the edit form.
$this->drupalGet('admin/structure/block/manage/' . $block['id']);
$this->clickLink(t('Delete'));
$this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block['settings[label]'])));
$this->assertRaw(t('Are you sure you want to delete the block @name?', array('@name' => $block['settings[label]'])));
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->assertRaw(t('The block %name has been deleted.', array('%name' => $block['settings[label]'])));
......@@ -226,7 +229,7 @@ function testBlock() {
$block = $this->drupalPlaceBlock('system_powered_by_block');
$this->drupalGet('admin/structure/block/manage/' . $block->id(), array('query' => array('destination' => 'admin')));
$this->clickLink(t('Delete'));
$this->assertRaw(t('Are you sure you want to delete the block %name?', array('%name' => $block->label())));
$this->assertRaw(t('Are you sure you want to delete the block @name?', array('@name' => $block->label())));
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->assertRaw(t('The block %name has been deleted.', array('%name' => $block->label())));
$this->assertUrl('admin');
......
......@@ -257,12 +257,15 @@ public function testMachineNameSuggestion() {
$url = 'admin/structure/block/add/test_block_instantiation/classy';
$this->drupalGet($url);
$this->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.');
$this->drupalPostForm($url, array(), 'Save block');
$edit = ['region' => 'content'];
$this->drupalPostForm($url, $edit, 'Save block');
$this->assertText('The block configuration has been saved.');
// Now, check to make sure the form starts by autoincrementing correctly.
$this->drupalGet($url);
$this->assertFieldByName('id', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.');
$this->drupalPostForm($url, array(), 'Save block');
$this->drupalPostForm($url, $edit, 'Save block');
$this->assertText('The block configuration has been saved.');
// And verify that it continues working beyond just the first two.
$this->drupalGet($url);
......@@ -292,7 +295,7 @@ public function testBlockPlacementIndicator() {
* Tests if validation errors are passed plugin form to the parent form.
*/
public function testBlockValidateErrors() {
$this->drupalPostForm('admin/structure/block/add/test_settings_validation/classy', ['settings[digits]' => 'abc'], t('Save block'));
$this->drupalPostForm('admin/structure/block/add/test_settings_validation/classy', ['region' => 'content', 'settings[digits]' => 'abc'], t('Save block'));
$arguments = [':message' => 'Only digits are allowed'];
$pattern = '//div[contains(@class,"messages messages--error")]/div[contains(text()[2],:message)]';
......
<?php
namespace Drupal\block\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* Tests the upgrade path for removal of disabled region.
*
* @see https://www.drupal.org/node/2513534
*
* @group Update
*/
class BlockRemoveDisabledRegionUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['block_test', 'language'];
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.update-test-block-disabled-2513534.php',
];
}
/**
* Tests that block context mapping is updated properly.
*/
public function testUpdateHookN() {
$this->runUpdates();
// Disable maintenance mode.
\Drupal::state()->set('system.maintenance_mode', FALSE);
// We finished updating so we can login the user now.
$this->drupalLogin($this->rootUser);
// Verify that a disabled block is in the default region.
$this->drupalGet('admin/structure/block');
$element = $this->xpath("//tr[contains(@data-drupal-selector, :block) and contains(@class, :status)]//select/option[@selected and @value=:region]",
[':block' => 'edit-blocks-pagetitle-1', ':status' => 'block-disabled', ':region' => 'header']);
$this->assertTrue(!empty($element));
// Verify that an enabled block is now disabled and in the default region.
$this->drupalGet('admin/structure/block');
$element = $this->xpath("//tr[contains(@data-drupal-selector, :block) and contains(@class, :status)]//select/option[@selected and @value=:region]",
[':block' => 'edit-blocks-pagetitle-2', ':status' => 'block-disabled', ':region' => 'header']);
$this->assertTrue(!empty($element));
}
}
......@@ -185,8 +185,10 @@ public function testViewsBlockForm() {
// Test that that machine name field is hidden from display and has been
// saved as expected from the default value.
$this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.');
// Save the block.
$this->drupalPostForm(NULL, array(), t('Save block'));
$edit = ['region' => 'content'];
$this->drupalPostForm(NULL, $edit, t('Save block'));
$storage = $this->container->get('entity_type.manager')->getStorage('block');
$block = $storage->load('views_block__test_view_block_block_1');
// This will only return a result if our new block has been created with the
......@@ -195,7 +197,7 @@ public function testViewsBlockForm() {
for ($i = 2; $i <= 3; $i++) {
// Place the same block again and make sure we have a new ID.
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, array(), t('Save block'));
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block'));
$block = $storage->load('views_block__test_view_block_block_1_' . $i);
// This will only return a result if our new block has been created with the
// expected machine name.
......@@ -204,7 +206,7 @@ public function testViewsBlockForm() {
// Tests the override capability of items per page.
$this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme);
$edit = array();
$edit = ['region' => 'content'];
$edit['settings[override][items_per_page]'] = 10;
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block'));
......@@ -222,7 +224,7 @@ public function testViewsBlockForm() {
$this->assertEqual(5, $config['items_per_page'], "'Items per page' is properly saved.");
// Tests the override of the label capability.
$edit = array();
$edit = ['region' => 'content'];
$edit['settings[views_label_checkbox]'] = 1;
$edit['settings[views_label]'] = 'Custom title';
$this->drupalPostForm('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme, $edit, t('Save block'));
......
<?php
namespace Drupal\Tests\block\Kernel;
use Drupal\block\Entity\Block;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\KernelTests\KernelTestBase;
use Drupal\simpletest\BlockCreationTrait;
/**
* Tests block_rebuild().
*
* @group block
*/
class BlockRebuildTest extends KernelTestBase {
use BlockCreationTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['block', 'system'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->container->get('theme_installer')->install(['stable', 'classy']);
$this->container->get('config.factory')->getEditable('system.theme')->set('default', 'classy')->save();
}
/**
* {@inheritdoc}
*/
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
// @todo Once block_rebuild() is refactored to auto-loadable code, remove
// this require statement.
require_once static::getDrupalRoot() . '/core/modules/block/block.module';
}
/**
* @covers ::block_rebuild
*/
public function testRebuildNoBlocks() {
block_rebuild();
$messages = drupal_get_messages();
$this->assertEquals([], $messages);
}
/**
* @covers ::block_rebuild
*/
public function testRebuildNoInvalidBlocks() {
$this->placeBlock('system_powered_by_block', ['region' => 'content']);
block_rebuild();
$messages = drupal_get_messages();
$this->assertEquals([], $messages);
}
/**
* @covers ::block_rebuild
*/
public function testRebuildInvalidBlocks() {
$this->placeBlock('system_powered_by_block', ['region' => 'content']);
$block1 = $this->placeBlock('system_powered_by_block');
$block2 = $this->placeBlock('system_powered_by_block');
$block2->disable()->save();
// Use the config API directly to bypass Block::preSave().
\Drupal::configFactory()->getEditable('block.block.' . $block1->id())->set('region', 'INVALID')->save();
\Drupal::configFactory()->getEditable('block.block.' . $block2->id())->set('region', 'INVALID')->save();
// Reload block entities.
$block1 = Block::load($block1->id());
$block2 = Block::load($block2->id());
$this->assertSame('INVALID', $block1->getRegion());
$this->assertTrue($block1->status());
$this->assertSame('INVALID', $block2->getRegion());
$this->assertFalse($block2->status());
block_rebuild();
// Reload block entities.
$block1 = Block::load($block1->id());
$block2 = Block::load($block2->id());
$messages = drupal_get_messages();
$expected = ['warning' => [new TranslatableMarkup('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block1->id(), '%region' => 'INVALID'])]];
$this->assertEquals($expected, $messages);
$default_region = system_default_region('classy');
$this->assertSame($default_region, $block1->getRegion());
$this->assertFalse($block1->status());
$this->assertSame($default_region, $block2->getRegion());
$this->assertFalse($block2->status());
}
}
......@@ -34,6 +34,8 @@ protected function setUp() {
parent::setUp();
$this->controller = $this->container->get('entity_type.manager')->getStorage('block');
$this->container->get('theme_installer')->install(['stark']);
}
/**
......@@ -66,6 +68,7 @@ protected function createTests() {
$entity = $this->controller->create(array(
'id' => 'test_block',
'theme' => 'stark',
'region' => 'content',
'plugin' => 'test_html',
));
$entity->save();
......@@ -84,7 +87,7 @@ protected function createTests() {
'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')),
'id' => 'test_block',
'theme' => 'stark',
'region' => '-1',
'region' => 'content',
'weight' => NULL,
'provider' => NULL,
'plugin' => 'test_html',
......@@ -111,7 +114,7 @@ protected function loadTests() {
$this->assertTrue($entity instanceof Block, 'The loaded entity is a Block.');
// Verify several properties of the block.
$this->assertEqual($entity->getRegion(), '-1');
$this->assertSame('content', $entity->getRegion());
$this->assertTrue($entity->status());
$this->assertEqual($entity->getTheme(), 'stark');
$this->assertTrue($entity->uuid());
......
......@@ -28,6 +28,10 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
// Install the themes used for this test.
$this->container->get('theme_installer')->install(['bartik', 'seven', 'test_theme']);
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
......@@ -37,9 +41,6 @@ protected function setUp() {
$config->set('admin', 'seven');
$config->save();
// Install one of D8's test themes.
\Drupal::service('theme_handler')->install(['test_theme']);
$this->executeMigrations([
'd6_filter_format',
'block_content_type',
......@@ -69,13 +70,14 @@ protected function setUp() {
* @param string $label_display
* The block label display setting.
*/
public function assertEntity($id, $visibility, $region, $theme, $weight, $label, $label_display) {
public function assertEntity($id, $visibility, $region, $theme, $weight, $label, $label_display, $status = TRUE) {
$block = Block::load($id);
$this->assertTrue($block instanceof Block);
$this->assertIdentical($visibility, $block->getVisibility());
$this->assertIdentical($region, $block->getRegion());
$this->assertIdentical($theme, $block->getTheme());
$this->assertIdentical($weight, $block->getWeight());
$this->assertIdentical($status, $block->status());
$config = $this->config('block.block.' . $id);
$this->assertIdentical($label, $config->get('settings.label'));
......@@ -122,7 +124,9 @@ public function testBlockMigration() {
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = TRUE;
$visibility['request_path']['pages'] = '/node/1';
$this->assertEntity('system', $visibility, 'footer', 'bartik', -5, '', '0');
// @todo https://www.drupal.org/node/2753939 This block is the footer region
// but Bartik in D8 does not have this region.
$this->assertEntity('system', $visibility, 'header', 'bartik', -5, '', '0', FALSE);
// Check menu blocks
$visibility = [];
......@@ -137,7 +141,9 @@ public function testBlockMigration() {
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = FALSE;
$visibility['request_path']['pages'] = '/node';
$this->assertEntity('block_1', $visibility, 'sidebar_second', 'bluemarine', -4, 'Another Static Block', 'visible');
// @todo https://www.drupal.org/node/2753939 The bluemarine theme does not
// exist.
$this->assertEntity('block_1', $visibility, '', 'bluemarine', -4, 'Another Static Block', 'visible', FALSE);
$visibility = [];
$this->assertEntity('block_2', $visibility, 'right', 'test_theme', -7, '', '0');
......
......@@ -33,6 +33,10 @@ class MigrateBlockTest extends MigrateDrupal7TestBase {
*/
protected function setUp() {
parent::setUp();
// Install the themes used for this test.
$this->container->get('theme_installer')->install(['bartik', 'seven']);
$this->installConfig(static::$modules);
$this->installEntitySchema('block_content');
......@@ -42,9 +46,6 @@ protected function setUp() {
$config->set('admin', 'seven');
$config->save();
// Install one of D8's test themes.
\Drupal::service('theme_handler')->install(['bartik']);
$this->executeMigrations([
'd7_filter_format',
'd7_user_role',
......@@ -77,7 +78,7 @@ protected function setUp() {
* @param string $label_display
* The block label display setting.
*/
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight, $label, $label_display) {
public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $theme, $weight, $label, $label_display, $status = TRUE) {
$block = Block::load($id);
$this->assertTrue($block instanceof Block);
/** @var \Drupal\block\BlockInterface $block */
......@@ -95,6 +96,7 @@ public function assertEntity($id, $plugin_id, array $roles, $pages, $region, $th
$this->assertIdentical($region, $block->getRegion());
$this->assertIdentical($theme, $block->getTheme());
$this->assertIdentical($weight, $block->getWeight());
$this->assertIdentical($status, $block->status());
$config = $this->config('block.block.' . $id);
$this->assertIdentical($label, $config->get('settings.label'));
......@@ -108,7 +110,9 @@ public function testBlockMigration() {
$this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'bartik', 0