Add test with broken property type.
1 unresolved thread
1 unresolved thread
Closes #3462156
Merge request reports
Activity
added 1 commit
- 35595b32 - Throw an exception if property type contains non-string value.
- Resolved by Nikita Malyshev
78 78 $valid_cta, 79 79 ['extension_type' => 'invalid'], 80 80 ); 81 $cta_with_null_prop_type = $valid_cta; 82 $cta_with_null_prop_type['props']['properties']['text']['type'] = NULL; 83 $cta_with_null_prop_type_list = $valid_cta; 84 $cta_with_null_prop_type_list['props']['properties']['text']['type'] = ['string', NULL]; I think it would be nice to test all possible non-string types here as a direct type and as part of the array with types. I suggest testing: int, float, array, boolean types. But for that, I have to refactor the data provider to \Generator, to make it more readable and easy to understand. Is that possible as part of this issue?
public static function dataProviderValidateDefinitionInvalid(): \Generator { $valid_cta = static::loadComponentDefinitionFromFs('my-cta'); $cta_with_missing_required = $valid_cta; unset($cta_with_missing_required['path']); yield 'missing required' => [$cta_with_missing_required]; $cta_with_invalid_class = $valid_cta; $cta_with_invalid_class['props']['properties']['attributes']['type'] = 'Drupal\Foo\Invalid'; yield 'invalid class' => [$cta_with_invalid_class]; $cta_with_invalid_enum = array_merge( $valid_cta, ['extension_type' => 'invalid'], ); yield 'invalid enum' => [$cta_with_invalid_enum]; // A list of property types that are not strings, but can be provided via // YAML. $non_string_types = [NULL, 123, 123.45, TRUE]; foreach ($non_string_types as $non_string_type) { $cta_with_non_string_prop_type = $valid_cta; $cta_with_non_string_prop_type['props']['properties']['text']['type'] = $non_string_type; yield "non string type ($non_string_type)" => [$cta_with_non_string_prop_type]; // Same, but as a part of the list of allowed types. $cta_with_non_string_prop_type['props']['properties']['text']['type'] = ['string', $non_string_type]; yield "non string type ($non_string_type) in a list of types" => [$cta_with_non_string_prop_type]; } // The array is a valid value for the 'type' parameter, but it is not // allowed as the allowed type. $cta_with_non_string_prop_type['props']['properties']['text']['type'] = ['string', []]; yield 'non string type (Array)' => [$cta_with_non_string_prop_type]; }
changed this line in version 8 of the diff
added 175 commits
-
f2bf9201...07abb808 - 174 commits from branch
project:11.x
- 6a6b24d3 - Merge branch drupal:11.x into 3462156-unhelpful-php-error
-
f2bf9201...07abb808 - 174 commits from branch
added 114 commits
-
ffd0f475...9258113b - 113 commits from branch
project:11.x
- a4b6c39c - Merge branch drupal:11.x into 3462156-unhelpful-php-error
-
ffd0f475...9258113b - 113 commits from branch
added 1 commit
- 5f7ad929 - Change the return comment of ::dataProviderValidateDefinitionInvalid().
Please register or sign in to reply