Loading core/modules/field/src/Plugin/ConfigAction/AddToAllBundles.php +2 −2 Original line number Diff line number Diff line Loading @@ -76,9 +76,9 @@ public function apply(string $configName, mixed $value): void { throw new ConfigActionException(sprintf('Field %s already exists.', $id)); } $storage->create([ 'label' => $value['label'], 'label' => $value['label'] ?? throw new ConfigActionException(sprintf('The `label` property must be set for %s.', $id)), 'bundle' => $bundle, 'description' => $value['description'], 'description' => $value['description'] ?? '', 'field_storage' => $field_storage, ])->save(); } Loading core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php +22 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,28 @@ public function testIgnoreExistingFields(): void { $this->assertSame('Set by config actions.', $field->getDescription()); } /** * Tests that the action fails when the label property is not set. */ public function testMissingLabel(): void { $contents = <<<YAML name: Instantiate field on all bundles config: import: entity_test_with_storage: - field.storage.entity_test.body actions: field.storage.entity_test.body: addToAllBundles: description: Set by config actions. YAML; $recipe = $this->createRecipe($contents); $this->expectException(ConfigActionException::class); $this->expectExceptionMessage('The `label` property must be set for entity_test.entity_test.body.'); RecipeRunner::processRecipe($recipe); } /** * Applies a recipe with the addToAllBundles action. * Loading Loading
core/modules/field/src/Plugin/ConfigAction/AddToAllBundles.php +2 −2 Original line number Diff line number Diff line Loading @@ -76,9 +76,9 @@ public function apply(string $configName, mixed $value): void { throw new ConfigActionException(sprintf('Field %s already exists.', $id)); } $storage->create([ 'label' => $value['label'], 'label' => $value['label'] ?? throw new ConfigActionException(sprintf('The `label` property must be set for %s.', $id)), 'bundle' => $bundle, 'description' => $value['description'], 'description' => $value['description'] ?? '', 'field_storage' => $field_storage, ])->save(); } Loading
core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php +22 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,28 @@ public function testIgnoreExistingFields(): void { $this->assertSame('Set by config actions.', $field->getDescription()); } /** * Tests that the action fails when the label property is not set. */ public function testMissingLabel(): void { $contents = <<<YAML name: Instantiate field on all bundles config: import: entity_test_with_storage: - field.storage.entity_test.body actions: field.storage.entity_test.body: addToAllBundles: description: Set by config actions. YAML; $recipe = $this->createRecipe($contents); $this->expectException(ConfigActionException::class); $this->expectExceptionMessage('The `label` property must be set for entity_test.entity_test.body.'); RecipeRunner::processRecipe($recipe); } /** * Applies a recipe with the addToAllBundles action. * Loading