Issue #3402548 by alexpott, mikelutz, el7cosmos: YamlFileLoaderTest fails if you have PECL yaml installed

merge-requests/5463/merge
catch 2023-11-19 18:02:13 +00:00
parent 6dc9ce0b01
commit aac47f0d69
2 changed files with 9 additions and 3 deletions

View File

@ -450,8 +450,8 @@ class YamlFileLoader
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file));
}
if ($invalid_keys = array_diff_key($content, array('parameters' => 1, 'services' => 1))) {
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid keys %s. Services have to be added under "services" and Parameters under "parameters".', $file, $invalid_keys));
if ($invalid_keys = array_keys(array_diff_key($content, array('parameters' => 1, 'services' => 1)))) {
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid root key(s) "%s". Services have to be added under "services" and Parameters under "parameters".', $file, implode('", "', $invalid_keys)));
}
return $content;

View File

@ -171,10 +171,16 @@ YAML,
],
'YAML must be valid' => [<<<YAML
do not:
do this for the love of Foo Bar!
do: this: for the love of Foo Bar!
YAML,
'The file "vfs://drupal/modules/example/example.yml" does not contain valid YAML',
],
'YAML must have expected keys' => [<<<YAML
"do not":
do: this
YAML,
'The service file "vfs://drupal/modules/example/example.yml" is not valid: it contains invalid root key(s) "do not". Services have to be added under "services" and Parameters under "parameters".',
],
];
}