function AddToAllBundlesConfigActionTest::testFailIfExists

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

Tests that the action can be set to fail if the field already exists.

File

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

Class

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

Namespace

Drupal\Tests\field\Kernel

Code

public function testFailIfExists() : void {
    $this->installConfig('node');
    node_add_body_field(NodeType::load('one'));
    $this->expectException(ConfigActionException::class);
    $this->expectExceptionMessage('Field node.one.body already exists.');
    $this->applyAction('field.storage.node.body', TRUE);
}

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