function AddComponentTest::testAddComponentToEmptyRegionThatIsNotFirst
Tests that adding a component to another section works as expected.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ Plugin/ ConfigAction/ AddComponentTest.php, line 345
Class
- AddComponentTest
- @coversDefaultClass \Drupal\layout_builder\Plugin\ConfigAction\AddComponent
Namespace
Drupal\Tests\layout_builder\Kernel\Plugin\ConfigActionCode
public function testAddComponentToEmptyRegionThatIsNotFirst() : void {
$this->configActionManager
->applyAction('addComponentToLayout', 'core.entity_view_display.entity_test.bundle_with_extra_fields.default', [
'section' => 2,
'position' => 4,
'component' => [
'region' => [
'layout_twocol_section' => 'second',
'layout_threecol_25_50_25' => 'bottom',
],
'default_region' => 'content',
'configuration' => [
'id' => 'my_plugin_id',
],
],
]);
$view_display = $this->container
->get(EntityTypeManagerInterface::class)
->getStorage('entity_view_display')
->load('entity_test.bundle_with_extra_fields.default');
$this->plugin
->setContextValue('display', $view_display);
$this->assertCount(1, $this->plugin
->getSection(0)
->getComponents());
$this->assertCount(0, $this->plugin
->getSection(1)
->getComponents());
$this->assertCount(1, $this->plugin
->getSection(2)
->getComponents());
$components = $this->plugin
->getSection(2)
->getComponents();
$uuid = end($components)->getUuid();
$this->assertSame('bottom', $components[$uuid]->getRegion());
$this->assertSame(0, $components[$uuid]->getWeight());
$this->assertSame([
'id' => 'my_plugin_id',
], $components[$uuid]->get('configuration'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.