function WildcardConfigActionsTest::testCreateForEachErrorsIfAlreadyExists

Tests that the createForEach action errs on conflict with existing config.

File

core/tests/Drupal/KernelTests/Core/Recipe/WildcardConfigActionsTest.php, line 231

Class

WildcardConfigActionsTest
Tests config actions targeting multiple entities using wildcards.

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testCreateForEachErrorsIfAlreadyExists() : void {
    $this->enableModules([
        'language',
    ]);
    ContentLanguageSettings::create([
        'target_entity_type_id' => 'node',
        'target_bundle' => 'one',
    ])->save();
    $this->expectExceptionMessage(ConfigActionException::class);
    $this->expectExceptionMessage('Entity language.content_settings.node.one exists');
    $this->container
        ->get('plugin.manager.config_action')
        ->applyAction('createForEach', 'node.type.*', [
        'language.content_settings.node.%bundle' => [
            'target_entity_type_id' => 'node',
            'target_bundle' => '%bundle',
        ],
    ]);
}

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