From dee8d88336b717ba6e9fa8aa543dda76c83f008d Mon Sep 17 00:00:00 2001 From: Dave Long Date: Tue, 15 Oct 2024 10:42:12 +0100 Subject: [PATCH] Issue #3480180 by alexpott: Recipe validation error in 10.4.x --- core/lib/Drupal/Core/Recipe/Recipe.php | 8 ++--- .../Core/Recipe/RecipeValidationTest.php | 29 ++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/core/lib/Drupal/Core/Recipe/Recipe.php b/core/lib/Drupal/Core/Recipe/Recipe.php index c9f5f055932..5e0d55b2e13 100644 --- a/core/lib/Drupal/Core/Recipe/Recipe.php +++ b/core/lib/Drupal/Core/Recipe/Recipe.php @@ -180,7 +180,7 @@ final class Recipe { ]), ]), 'input' => new Optional([ - new Type('associative_array'), + new Type('array'), new All([ new Collection( fields: [ @@ -192,7 +192,7 @@ final class Recipe { // There can be an optional set of constraints, which is an // associative array of arrays, as in config schema. 'constraints' => new Optional([ - new Type('associative_array'), + new Type('array'), ]), 'data_type' => [ // The data type must be known to the typed data system. @@ -211,7 +211,7 @@ final class Recipe { new Choice(['ask', 'askHidden', 'confirm', 'choice']), ], 'arguments' => new Optional([ - new Type('associative_array'), + new Type('array'), ]), ]), ]), @@ -224,7 +224,7 @@ final class Recipe { 'value' => new Optional(), 'config' => new Optional([ new Sequentially([ - new Type('list'), + new Type('array'), new Count(2), new All([ new Type('string'), diff --git a/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php b/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php index 55c140f2b87..fe736e90062 100644 --- a/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php @@ -351,15 +351,13 @@ YAML, yield 'input definitions are an indexed array' => [ << ['This value should be of type associative_array.'], + '[input]' => [ + 'This value should be of type array.', + 'This value should be of type iterable.', + ], ], ]; yield 'input data type is missing' => [ @@ -413,14 +411,13 @@ input: foo: data_type: string description: 'Constraints need to be associative' - constraints: - - Type: string + constraints: false default: source: value value: Here be dragons YAML, [ - '[input][foo][constraints]' => ['This value should be of type associative_array.'], + '[input][foo][constraints]' => ['This value should be of type array.'], ], ]; yield 'input data type is unknown' => [ @@ -499,13 +496,13 @@ input: description: 'Prompt arguments must be associative' prompt: method: ask - arguments: [1, 2] + arguments: false default: source: value value: Here be dragons YAML, [ - '[input][foo][prompt][arguments]' => ['This value should be of type associative_array.'], + '[input][foo][prompt][arguments]' => ['This value should be of type array.'], ], ]; yield 'input definition without default value' => [ @@ -552,7 +549,7 @@ input: config: 'system.site:mail' YAML, [ - '[input][foo][default][config]' => ['This value should be of type list.'], + '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has too few values' => [ @@ -583,12 +580,10 @@ input: method: ask default: source: config - config: - name: system.site - key: mail + config: false YAML, [ - '[input][foo][default][config]' => ['This value should be of type list.'], + '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has non-string values' => [