function AddComponentTest::testDerivativeDefinitions

Tests that the deriver produces the expected derivatives.

File

core/modules/layout_builder/tests/src/Kernel/Plugin/ConfigAction/AddComponentTest.php, line 410

Class

AddComponentTest
Tests that `addComponentToLayout` config action.

Namespace

Drupal\Tests\layout_builder\Kernel\Plugin\ConfigAction

Code

public function testDerivativeDefinitions() : void {
  $singular = $this->configActionManager
    ->getDefinition('add_layout_component:addComponentToLayout');
  $plural = $this->configActionManager
    ->getDefinition('add_layout_component:addComponentsToLayout');
  // These actions should be limited to entity types that carry section lists.
  $this->assertSame([
    'entity_view_display',
  ], $singular['entity_types']);
  // The `multiple` flag should differ.
  $this->assertFalse($singular['multiple']);
  $this->assertTrue($plural['multiple']);
  // There should only be two derivatives (the singular and the plural).
  $definitions = array_filter(array_keys($this->configActionManager
    ->getDefinitions()), fn(string $id): bool => str_starts_with($id, 'add_layout_component:'));
  $this->assertCount(2, $definitions);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.