function ConfigActionsTest::testLayoutBuilderActions
Tests config actions exposed by Layout Builder.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ ConfigActionsTest.php, line 30
Class
- ConfigActionsTest
- @group Recipe
Namespace
Drupal\Tests\layout_builder\KernelCode
public function testLayoutBuilderActions() : void {
/** @var \Drupal\Core\Config\Action\ConfigActionManager $manager */
$manager = $this->container
->get('plugin.manager.config_action');
EntityTestBundle::create([
'id' => 'test',
])->save();
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = $this->container
->get(EntityDisplayRepositoryInterface::class);
/** @var \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay $display */
$display = $display_repository->getViewDisplay('entity_test_with_bundle', 'test');
$this->assertInstanceOf(LayoutBuilderEntityViewDisplay::class, $display);
$display->save();
$this->assertFalse($display->isLayoutBuilderEnabled());
$manager->applyAction('enableLayoutBuilder', $display->getConfigDependencyName(), []);
$this->assertTrue($display_repository->getViewDisplay('entity_test_with_bundle', 'test')
->isLayoutBuilderEnabled());
$this->assertFalse($display->isOverridable());
$manager->applyAction('allowLayoutOverrides', $display->getConfigDependencyName(), TRUE);
$this->assertTrue($display_repository->getViewDisplay('entity_test_with_bundle', 'test')
->isOverridable());
$manager->applyAction('allowLayoutOverrides', $display->getConfigDependencyName(), FALSE);
$this->assertFalse($display_repository->getViewDisplay('entity_test_with_bundle', 'test')
->isOverridable());
$manager->applyAction('disableLayoutBuilder', $display->getConfigDependencyName(), []);
$this->assertFalse($display_repository->getViewDisplay('entity_test_with_bundle', 'test')
->isLayoutBuilderEnabled());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.