diff --git a/core/modules/block/src/Tests/BlockInvalidRegionTest.php b/core/modules/block/src/Tests/BlockInvalidRegionTest.php index 438a0c1..99ef06d 100644 --- a/core/modules/block/src/Tests/BlockInvalidRegionTest.php +++ b/core/modules/block/src/Tests/BlockInvalidRegionTest.php @@ -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'); diff --git a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php index 4572f7d..5704476 100644 --- a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +++ b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php @@ -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' => NULL, + '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(), NULL); + $this->assertSame('content', $entity->getRegion()); $this->assertTrue($entity->status()); $this->assertEqual($entity->getTheme(), 'stark'); $this->assertTrue($entity->uuid()); diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php index 1ceadd1..4b522f0 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php @@ -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', diff --git a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php index 571c210..ce7992d 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php @@ -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', diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php index af3d658..ebf9e05 100644 --- a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\views\Kernel\Handler; -use Drupal\block\Entity\Block; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormState; +use Drupal\simpletest\BlockCreationTrait; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Entity\View; use Drupal\views\Views; @@ -17,6 +17,8 @@ */ class AreaEntityTest extends ViewsKernelTestBase { + use BlockCreationTrait; + /** * Modules to enable. * @@ -42,14 +44,15 @@ protected function setUp($import_test_views = TRUE) { * {@inheritdoc} */ protected function setUpFixtures() { + // Install the themes used for this test. + $this->container->get('theme_installer')->install(['bartik']); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'bartik')->save(); + $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); $this->installConfig(['entity_test']); - Block::create([ - 'id' => 'test_block', - 'plugin' => 'system_main_block', - ])->save(); + $this->placeBlock('system_main_block', ['id' => 'test_block']); parent::setUpFixtures(); } diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php index 457c635..3c6ef61 100644 --- a/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\views\Kernel\Handler; use Drupal\block\Entity\Block; +use Drupal\simpletest\BlockCreationTrait; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Views; @@ -14,6 +15,8 @@ */ class AreaOrderTest extends ViewsKernelTestBase { + use BlockCreationTrait; + /** * Modules to enable. * @@ -32,23 +35,21 @@ class AreaOrderTest extends ViewsKernelTestBase { * {@inheritdoc} */ protected function setUpFixtures() { - Block::create( - [ - 'id' => 'bartik_branding', - 'theme' => 'bartik', - 'plugin' => 'system_branding_block', - 'weight' => 1, - ] - )->save(); + // Install the themes used for this test. + $this->container->get('theme_installer')->install(['bartik']); + + $this->placeBlock('system_branding_block', [ + 'id' => 'bartik_branding', + 'theme' => 'bartik', + 'plugin' => 'system_branding_block', + 'weight' => 1, + ]); - Block::create( - [ - 'id' => 'bartik_powered', - 'theme' => 'bartik', - 'plugin' => 'system_powered_by_block', - 'weight' => 2, - ] - )->save(); + $this->placeBlock('system_powered_by_block', [ + 'id' => 'bartik_powered', + 'theme' => 'bartik', + 'weight' => 2, + ]); parent::setUpFixtures(); }