function 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 <a href="/api/drupal/core%21modules%21field%21src%21Plugin%21ConfigAction%21AddToAllBundles.php/class/AddToAllBundles/11.x" title="Adds a field to all bundles of its target entity type." class="local">\Drupal\field\Plugin\ConfigAction\AddToAllBundles</a>
Namespace
Drupal\Tests\field\KernelCode
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.