function AddToAllBundlesConfigActionTest::applyAction

Same name in other branches
  1. 10 core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php \Drupal\Tests\field\Kernel\AddToAllBundlesConfigActionTest::applyAction()

Applies a recipe with the addToAllBundles action.

Parameters

string $config_name: The name of the config object which should run the addToAllBundles action.

bool $fail_if_exists: (optional) Whether the action should fail if the field already exists on any bundle. Defaults to FALSE.

3 calls to AddToAllBundlesConfigActionTest::applyAction()
AddToAllBundlesConfigActionTest::testFailIfExists in core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php
Tests that the action can be set to fail if the field already exists.
AddToAllBundlesConfigActionTest::testIgnoreExistingFields in core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php
Tests that the action will ignore existing fields by default.
AddToAllBundlesConfigActionTest::testInstantiateNewFieldOnAllBundles in core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php
Tests instantiating a field on all bundles of an entity type.

File

core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php, line 129

Class

AddToAllBundlesConfigActionTest
@covers \Drupal\field\Plugin\ConfigAction\AddToAllBundles

Namespace

Drupal\Tests\field\Kernel

Code

private function applyAction(string $config_name, bool $fail_if_exists = FALSE) : void {
    $fail_if_exists = var_export($fail_if_exists, TRUE);
    $contents = <<<YAML
name: Instantiate field on all bundles
config:
  import:
    node:
      - field.storage.node.body
  actions:
    {<span class="php-variable">$config_name</span>}:
      addToAllBundles:
        label: Body field label
        description: Set by config actions.
        fail_if_exists: {<span class="php-variable">$fail_if_exists</span>}
YAML;
    $recipe = $this->createRecipe($contents);
    RecipeRunner::processRecipe($recipe);
}

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