13
13
use Generator ;
14
14
use PHPUnit \Framework \TestCase ;
15
15
16
- use function assert ;
17
- use function is_array ;
18
16
use function sort ;
19
17
20
18
class ColocatedMappingDriverTest extends TestCase
21
19
{
22
20
public function testAddGetPaths (): void
23
21
{
24
- $ driver = $ this ->createPathDriver (__DIR__ . '/_files/colocated ' );
22
+ $ driver = $ this ->createDriver (__DIR__ . '/_files/colocated ' );
25
23
self ::assertSame ([
26
24
__DIR__ . '/_files/colocated ' ,
27
25
], $ driver ->getPaths ());
@@ -37,7 +35,7 @@ public function testAddGetPaths(): void
37
35
38
36
public function testAddGetExcludePaths (): void
39
37
{
40
- $ driver = $ this ->createPathDriver (__DIR__ . '/_files/colocated ' );
38
+ $ driver = $ this ->createDriver (__DIR__ . '/_files/colocated ' );
41
39
self ::assertSame ([], $ driver ->getExcludePaths ());
42
40
43
41
$ driver ->addExcludePaths (['/test/path1 ' , '/test/path2 ' ]);
@@ -50,7 +48,7 @@ public function testAddGetExcludePaths(): void
50
48
51
49
public function testGetSetFileExtension (): void
52
50
{
53
- $ driver = $ this ->createPathDriver (__DIR__ . '/_files/colocated ' );
51
+ $ driver = $ this ->createDriver (__DIR__ . '/_files/colocated ' );
54
52
self ::assertSame ('.php ' , $ driver ->getFileExtension ());
55
53
56
54
$ driver ->setFileExtension ('.php1 ' );
@@ -59,61 +57,37 @@ public function testGetSetFileExtension(): void
59
57
}
60
58
61
59
/** @dataProvider pathProvider */
62
- public function testGetAllClassNamesForPath (string $ path ): void
60
+ public function testGetAllClassNames (string $ path ): void
63
61
{
64
- $ driver = $ this ->createPathDriver ($ path );
62
+ $ driver = $ this ->createDriver ($ path );
65
63
66
64
$ classes = $ driver ->getAllClassNames ();
67
65
68
66
sort ($ classes );
69
67
self ::assertSame ([Entity::class, EntityFixture::class], $ classes );
70
68
}
71
69
72
- public function testGetAllClassNamesForIterableFilePathNames (): void
73
- {
74
- $ driver = $ this ->createFilePathNamesDriver ([
75
- __DIR__ . '/_files/colocated/Entity.php ' ,
76
- __DIR__ . '/_files/colocated/TestClass.php ' ,
77
- ]);
78
-
79
- $ classes = $ driver ->getAllClassNames ();
80
-
81
- self ::assertSame ([Entity::class], $ classes , 'The driver should only return the class names from the provided file path names, excluding transient class names. ' );
82
- }
83
-
84
70
/** @return Generator<string, array{string}> */
85
71
public static function pathProvider (): Generator
86
72
{
87
73
yield 'straigthforward path ' => [__DIR__ . '/_files/colocated ' ];
88
74
yield 'winding path ' => [__DIR__ . '/../Mapping/_files/colocated ' ];
89
75
}
90
76
91
- private function createPathDriver (string $ path ): MyDriver
77
+ private function createDriver (string $ path ): MyDriver
92
78
{
93
79
return new MyDriver ([$ path ]);
94
80
}
95
-
96
- /** @param list<string> $paths */
97
- private function createFilePathNamesDriver (array $ paths ): MyDriver
98
- {
99
- return new MyDriver ($ paths , true );
100
- }
101
81
}
102
82
103
83
final class MyDriver implements MappingDriver
104
84
{
105
85
use ColocatedMappingDriver;
106
86
107
- /** @param iterable <string> $paths Source file path names */
108
- public function __construct (iterable $ paths, bool $ sourceFilePathNames = false )
87
+ /** @param non-empty-list <string> $paths One or multiple paths where mapping classes can be found. */
88
+ public function __construct (array $ paths )
109
89
{
110
- if (! $ sourceFilePathNames ) {
111
- assert (is_array ($ paths ));
112
-
113
- $ this ->addPaths ($ paths );
114
- } else {
115
- $ this ->sourceFilePathNames = $ paths ;
116
- }
90
+ $ this ->addPaths ($ paths );
117
91
}
118
92
119
93
/**
0 commit comments