You are here

public function YamlTest::providerYamlFilesInCore in Drupal 8

Same name and namespace in other branches
  1. 9 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 120

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