function BlockContentCreationTest::testConfigDependencies
Same name in other branches
- 9 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testConfigDependencies()
- 10 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testConfigDependencies()
- 11.x core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testConfigDependencies()
Test that placed content blocks create a dependency in the block placement.
File
-
core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php, line 297
Class
- BlockContentCreationTest
- Create a block and test saving it.
Namespace
Drupal\Tests\block_content\FunctionalCode
public function testConfigDependencies() {
$block = $this->createBlockContent();
// Place the block.
$block_placement_id = mb_strtolower($block->label());
$instance = [
'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', [
$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.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.