File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 99 */
1010namespace PHPUnit \Util \Xml ;
1111
12+ use function assert ;
1213use function defined ;
1314use function is_file ;
15+ use function rsort ;
1416use function sprintf ;
17+ use DirectoryIterator ;
1518use PHPUnit \Runner \Version ;
1619
1720/**
1821 * @internal This class is not covered by the backward compatibility promise for PHPUnit
1922 */
2023final class SchemaFinder
2124{
25+ /**
26+ * @psalm-return non-empty-list<non-empty-string>
27+ */
28+ public function available (): array
29+ {
30+ $ result = [Version::series ()];
31+
32+ foreach ((new DirectoryIterator ($ this ->path () . 'schema ' )) as $ file ) {
33+ if ($ file ->isDot ()) {
34+ continue ;
35+ }
36+
37+ $ version = $ file ->getBasename ('.xsd ' );
38+
39+ assert (!empty ($ version ));
40+
41+ $ result [] = $ version ;
42+ }
43+
44+ rsort ($ result );
45+
46+ return $ result ;
47+ }
48+
2249 /**
2350 * @throws Exception
2451 */
Original file line number Diff line number Diff line change 99 */
1010namespace PHPUnit \Util \Xml ;
1111
12+ use function count ;
1213use PHPUnit \Framework \TestCase ;
1314use PHPUnit \Runner \Version ;
1415
1920 */
2021final class SchemaFinderTest extends TestCase
2122{
22- public function testFindsExistingSchemaForComposerInstallation (): void
23+ public function testListsAvailableSchemas (): void
24+ {
25+ $ schemas = (new SchemaFinder )->available ();
26+
27+ $ this ->assertSame ((new Version )->series (), $ schemas [0 ]);
28+ $ this ->assertSame ('8.5 ' , $ schemas [count ($ schemas ) - 1 ]);
29+ }
30+
31+ public function testFindsExistingSchema (): void
2332 {
2433 $ this ->assertFileExists ((new SchemaFinder )->find ((new Version )->series ()));
2534 }
2635
27- public function testDoesNotFindNonExistentSchemaForComposerInstallation (): void
36+ public function testDoesNotFindNonExistentSchema (): void
2837 {
2938 $ this ->expectException (Exception::class);
3039
You can’t perform that action at this time.
0 commit comments