Repository: symfony/symfony
File: src/Symfony/Component/Yaml/Tests/YamlTestSuiteTest.php (PHP)

Code before:

        if (!$isErrorExpected) {
            $this->assertEquals($expected, $yaml, 'Test case "'.$testName.'" ('.$shortcode.') failed.');
        }
    }

    public static function yamlTestSuiteProvider(): array
    {
        if (!file_exists(__DIR__.\DIRECTORY_SEPARATOR.'yaml-test-suite')) {
            self::markTestSkipped('The YAML test suite is not available.');
        }

        $dataDir = __DIR__.\DIRECTORY_SEPARATOR.'yaml-test-suite';
        $shortcodeDirs = glob($dataDir.\DIRECTORY_SEPARATOR.'*', \GLOB_ONLYDIR);

        $testDirs = [];
        foreach ($shortcodeDirs as $shortcodeDir) {
            $shortcode = basename($shortcodeDir);

            // ignore metadata directories referencing other test cases by name
            if (\in_array($shortcode, ['name', 'tags'], true)) {
                continue;
            }

            if (file_exists($shortcodeDir.\DIRECTORY_SEPARATOR.'in.yaml')) {
                $testDirs[] = self::createTestItem($shortcode, $shortcodeDir);
            } else {
                $subDirs = glob($shortcodeDir.\DIRECTORY_SEPARATOR.'*', \GLOB_ONLYDIR);
                foreach ($subDirs as $subDir) {
                    if (file_exists($subDir.\DIRECTORY_SEPARATOR.'in.yaml')) {
                        $shortcodeSub = $shortcode.'-'.basename($subDir);
                        $testDirs[] = self::createTestItem($shortcodeSub, $subDir);
                    }
                }
            }
        }

        return $testDirs;
    }

    private static function createTestItem(string $shortcode, string $dir): array
    {
        $isError = file_exists($dir.\DIRECTORY_SEPARATOR.'error');
        $json = file_exists($dir.\DIRECTORY_SEPARATOR.'in.json') ? json_decode(file_get_contents($dir.\DIRECTORY_SEPARATOR.'in.json'), true) : null;
        $testName = is_file($dir.\DIRECTORY_SEPARATOR.'===') ? trim(file_get_contents($dir.\DIRECTORY_SEPARATOR.'===')) : $shortcode;

        return [$testName, $shortcode, $dir, $isError, $json];
    }
}


Review comment (suggestion):
The test identifier (the short code) should be used as key in the provided iterable to make things easier (for instance, we will be able to filter tests by shortcode as the shortcode will be part of the test name)

Code after:
        '74H7',
        '7FWL',
        '7T8X',
        '7W2P',
        '7Z25',
        '87E4',
        '8G76',
        '93JH',
        '98YD',
        '9BXH',
        '9C9N',
        '9DXL',
        '9JBA',
        '9KAX',
        '9MAG',
        '9MMA',
        '9MMW',
        '9MQT-01',
        '9WXW',
        '9YRD',
        'A2M4',
        'AVM7',
        'B63P',
        'BEC7',
        'BF9H',
        'BS4K',
        'BU8L',
        'C4HZ',
        'CC74',
        'CFD4',
        'CML9',
        'CN3R',
        'CTN5',
        'CUP7',
        'CVW2',
        'CXX2',
        'DFF7',
        'DK4H',
        'DK95-00',
        'DK95-01',
        'DK95-03',
        'DK95-04',
        'DK95-07',
        'DWX9',
        'E76Z',
        'EB22',
        'EHF6',
        'F2C7',
        'FH7J',
        'FRK4',
        'G5U8',