function AddToAllBundlesConfigActionTest::testFailIfExists
Same name and namespace in other branches
- 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 86
Class
- AddToAllBundlesConfigActionTest
- @covers \Drupal\field\Plugin\ConfigAction\AddToAllBundles[[api-linebreak]]
Namespace
Drupal\Tests\field\KernelCode
public function testFailIfExists() : void {
$this->installConfig('node');
$field_storage = FieldStorageConfig::loadByName('node', 'body');
// Manually create the field.
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'one',
'label' => 'Body',
]);
$field->save();
$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.