function YamlTest::testYamlFiles

Same name in other branches
  1. 8.9.x 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 74

Class

YamlTest
@coversDefaultClass \Drupal\Component\Serialization\Yaml @group Serialization

Namespace

Drupal\Tests\Component\Serialization

Code

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());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.