public function YamlTest::testYamlFiles in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest::testYamlFiles()
Tests all YAML files are decoded in the same way with Symfony and PECL.
This test is a little bit slow but it tests that we do not have any bugs in our YAML that might not be decoded correctly in any of our implementations.
@todo This should exist as an integration test not part of our unit tests. https://www.drupal.org/node/2597730
@requires extension yaml @dataProvider providerYamlFilesInCore
File
- core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlTest.php, line 68
Class
- YamlTest
- @coversDefaultClass \Drupal\Component\Serialization\Yaml @group Serialization
Namespace
Drupal\Tests\Component\SerializationCode
public function testYamlFiles($file) {
$data = file_get_contents($file);
try {
$this
->assertEquals(YamlSymfony::decode($data), YamlPecl::decode($data), $file);
} catch (InvalidDataTypeException $e) {
// Provide file context to the failure so the exception message is useful.
$this
->fail("Exception thrown parsing {$file}:\n" . $e
->getMessage());
}
}