function YamlTest::providerYamlFilesInCore

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Serialization/YamlTest.php \Drupal\Tests\Component\Serialization\YamlTest::providerYamlFilesInCore()

Data provider that lists all YAML files in core.

File

core/tests/Drupal/Tests/Component/Serialization/YamlTest.php, line 126

Class

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

Namespace

Drupal\Tests\Component\Serialization

Code

public function providerYamlFilesInCore() {
    $files = [];
    $dirs = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . '/../../../../../', \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
    foreach ($dirs as $dir) {
        $pathname = $dir->getPathname();
        // Exclude core/node_modules.
        if ($dir->getExtension() == 'yml' && strpos($pathname, '/../../../../../node_modules') === FALSE) {
            if (strpos($dir->getRealPath(), 'invalid_file') !== FALSE) {
                // There are some intentionally invalid files provided for testing
                // library API behaviors, ignore them.
                continue;
            }
            $files[] = [
                $dir->getRealPath(),
            ];
        }
    }
    return $files;
}

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