public function BlockContentCreationTest::testConfigDependencies in Drupal 10
Same name and namespace in other branches
- 8 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testConfigDependencies()
- 9 core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php \Drupal\Tests\block_content\Functional\BlockContentCreationTest::testConfigDependencies()
Tests placed content blocks create a dependency in the block placement.
File
- core/
modules/ block_content/ tests/ src/ Functional/ BlockContentCreationTest.php, line 280
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
->drupalGet($url);
$this
->submitForm($instance, 'Save block');
$dependencies = \Drupal::service('config.manager')
->findConfigEntityDependenciesAsEntities('content', [
$block
->getConfigDependencyName(),
]);
$block_placement = reset($dependencies);
$this
->assertEquals($block_placement_id, $block_placement
->id(), "The block placement config entity has a dependency on the block content entity.");
}