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 9
9
*/
10
10
namespace PHPUnit \Util \Xml ;
11
11
12
+ use function assert ;
12
13
use function defined ;
13
14
use function is_file ;
15
+ use function rsort ;
14
16
use function sprintf ;
17
+ use DirectoryIterator ;
15
18
use PHPUnit \Runner \Version ;
16
19
17
20
/**
18
21
* @internal This class is not covered by the backward compatibility promise for PHPUnit
19
22
*/
20
23
final class SchemaFinder
21
24
{
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
+
22
49
/**
23
50
* @throws Exception
24
51
*/
Original file line number Diff line number Diff line change 9
9
*/
10
10
namespace PHPUnit \Util \Xml ;
11
11
12
+ use function count ;
12
13
use PHPUnit \Framework \TestCase ;
13
14
use PHPUnit \Runner \Version ;
14
15
19
20
*/
20
21
final class SchemaFinderTest extends TestCase
21
22
{
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
23
32
{
24
33
$ this ->assertFileExists ((new SchemaFinder )->find ((new Version )->series ()));
25
34
}
26
35
27
- public function testDoesNotFindNonExistentSchemaForComposerInstallation (): void
36
+ public function testDoesNotFindNonExistentSchema (): void
28
37
{
29
38
$ this ->expectException (Exception::class);
30
39
You can’t perform that action at this time.
0 commit comments