function AddComponentTest::testActionFailsIfEntityNotFound

Tests that applying the config action to a missing entity fails.

File

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

Class

AddComponentTest
@coversDefaultClass \Drupal\layout_builder\Plugin\ConfigAction\AddComponent

Namespace

Drupal\Tests\layout_builder\Kernel\Plugin\ConfigAction

Code

public function testActionFailsIfEntityNotFound() : void {
    $this->expectException(ConfigActionException::class);
    $this->expectExceptionMessage('No entity found for applying the addComponentToLayout action.');
    $this->configActionManager
        ->applyAction('addComponentToLayout', 'core.entity_view_display.entity_test.bundle_with_extra_fields.missing_view_mode', [
        'section' => 0,
        'position' => 4,
        'component' => [
            'default_region' => 'content',
            'configuration' => [
                'id' => 'my_plugin_id',
            ],
        ],
    ]);
}

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