10
10
use Cycle \Schema \Provider \Exception \SchemaFileNotFoundException ;
11
11
use Cycle \Schema \Provider \FromFilesSchemaProvider ;
12
12
13
- class FromFilesSchemaProviderTest extends BaseSchemaProvider
13
+ final class FromFilesSchemaProviderTest extends BaseSchemaProvider
14
14
{
15
15
protected const READ_CONFIG = ['files ' => [__DIR__ . '/Stub/FromFilesSchemaProvider/schema1.php ' ]];
16
16
protected const READ_CONFIG_SCHEMA = ['user ' => []];
17
17
18
- public static function EmptyConfigProvider (): array
18
+ public function testConfig (): void
19
19
{
20
- return [
21
- [
22
- [],
23
- ],
24
- [
25
- ['files ' => []],
26
- ],
27
- ];
20
+ $ this ->assertSame (
21
+ ['files ' => ['foo ' , 'bar ' ], 'strict ' => false ],
22
+ FromFilesSchemaProvider::config (['foo ' , 'bar ' ])
23
+ );
24
+
25
+ $ this ->assertSame (
26
+ ['files ' => ['foo ' , 'bar ' ], 'strict ' => true ],
27
+ FromFilesSchemaProvider::config (['foo ' , 'bar ' ], true )
28
+ );
28
29
}
29
30
30
31
/**
31
- * @dataProvider EmptyConfigProvider
32
+ * @dataProvider emptyConfigProvider
32
33
*/
33
34
public function testWithConfigEmpty (array $ config ): void
34
35
{
@@ -48,26 +49,15 @@ public function testWithConfigInvalidFiles(): void
48
49
$ schemaProvider ->withConfig (['files ' => __DIR__ . '/Stub/FromFilesSchemaProvider/schema1.php ' ]);
49
50
}
50
51
51
- public static function FileListBadValuesProvider (): array
52
- {
53
- return [
54
- [null ],
55
- [42 ],
56
- [STDIN ],
57
- [[]],
58
- [new \SplFileInfo (__FILE__ )],
59
- ];
60
- }
61
-
62
52
/**
63
- * @dataProvider FileListBadValuesProvider
53
+ * @dataProvider fileListBadValuesProvider
64
54
*/
65
55
public function testWithConfigInvalidValueInFileList ($ value ): void
66
56
{
67
57
$ schemaProvider = $ this ->createSchemaProvider ();
68
58
69
59
$ this ->expectException (ConfigurationException::class);
70
- $ this ->expectExceptionMessage ('The `files` parameter must contain string values. ' );
60
+ $ this ->expectExceptionMessage ('The `files` parameter must contain non-empty string values. ' );
71
61
$ schemaProvider ->withConfig (['files ' => [$ value ]]);
72
62
}
73
63
@@ -204,6 +194,22 @@ public function testClear(): void
204
194
$ this ->assertFalse ($ schemaProvider ->clear ());
205
195
}
206
196
197
+ public static function emptyConfigProvider (): \Traversable
198
+ {
199
+ yield [[]];
200
+ yield [['files ' => []]];
201
+ }
202
+
203
+ public static function fileListBadValuesProvider (): \Traversable
204
+ {
205
+ yield [null ];
206
+ yield [42 ];
207
+ yield [STDIN ];
208
+ yield [[]];
209
+ yield [['' ]];
210
+ yield [new \SplFileInfo (__FILE__ )];
211
+ }
212
+
207
213
protected function createSchemaProvider (array $ config = null ): FromFilesSchemaProvider
208
214
{
209
215
$ provider = new FromFilesSchemaProvider ();
0 commit comments