Commit 2155f016 authored by catch's avatar catch
Browse files

Issue #3402548 by alexpott, mikelutz, el7cosmos: YamlFileLoaderTest fails if...

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

(cherry picked from commit aac47f0d)
(cherry picked from commit bea5ccb1)
parent 870265ac
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -446,8 +446,8 @@ private function validate($content, $file)
            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;
+7 −1
Original line number Diff line number Diff line
@@ -171,10 +171,16 @@ public function providerTestExceptions() {
      ],
      '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".',
      ],
    ];
  }