public function BlockContentCreationTest::testConfigDependencies in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/block_content/src/Tests/BlockContentCreationTest.php \Drupal\block_content\Tests\BlockContentCreationTest::testConfigDependencies()
Test that placed content blocks create a dependency in the block placement.
File
- core/
modules/ block_content/ src/ Tests/ BlockContentCreationTest.php, line 289 - Contains \Drupal\block_content\Tests\BlockContentCreationTest.
Class
- BlockContentCreationTest
- Create a block and test saving it.
Namespace
Drupal\block_content\TestsCode
public function testConfigDependencies() {
$block = $this
->createBlockContent();
// Place the block.
$block_placement_id = Unicode::strtolower($block
->label());
$instance = array(
'id' => $block_placement_id,
'settings[label]' => $block
->label(),
'region' => 'sidebar_first',
);
$block = BlockContent::load(1);
$url = 'admin/structure/block/add/block_content:' . $block
->uuid() . '/' . $this
->config('system.theme')
->get('default');
$this
->drupalPostForm($url, $instance, t('Save block'));
$dependencies = \Drupal::service('config.manager')
->findConfigEntityDependentsAsEntities('content', array(
$block
->getConfigDependencyName(),
));
$block_placement = reset($dependencies);
$this
->assertEqual($block_placement_id, $block_placement
->id(), "The block placement config entity has a dependency on the block content entity.");
}