@@ -322,32 +322,58 @@ public function testResolveConfigFileChooseFileWithPathArrayAndConfig()
322322 static ::assertInstanceOf (\PhpCsFixer \Console \ConfigurationResolver::class, $ resolver );
323323 }
324324
325- public function testResolvePathRelativeA ()
325+ /**
326+ * @param array<int, string> $paths
327+ * @param string $cwd
328+ * @param array<int, string> $expectedPaths
329+ *
330+ * @dataProvider providePathCases
331+ */
332+ public function testResolvePath (array $ paths , $ cwd , array $ expectedPaths )
326333 {
327334 $ resolver = $ this ->createConfigurationResolver (
328- ['path ' => [ ' Command ' ] ],
335+ ['path ' => $ paths ],
329336 null ,
330- __DIR__
337+ $ cwd
331338 );
332339
333- static ::assertSame ([ __DIR__ .\ DIRECTORY_SEPARATOR . ' Command ' ] , $ resolver ->getPath ());
340+ static ::assertSame ($ expectedPaths , $ resolver ->getPath ());
334341 }
335342
336- public function testResolvePathRelativeB ()
343+ public function providePathCases ()
337344 {
338- $ resolver = $ this ->createConfigurationResolver (
339- ['path ' => [basename (__DIR__ )]],
340- null ,
341- \dirname (__DIR__ )
342- );
345+ yield [
346+ ['Command ' ],
347+ __DIR__ ,
348+ [__DIR__ .\DIRECTORY_SEPARATOR .'Command ' ],
349+ ];
350+
351+ yield [
352+ [basename (__DIR__ )],
353+ \dirname (__DIR__ ),
354+ [__DIR__ ],
355+ ];
356+
357+ yield [
358+ [' Command ' ],
359+ __DIR__ ,
360+ [__DIR__ .\DIRECTORY_SEPARATOR .'Command ' ],
361+ ];
343362
344- static ::assertSame ([__DIR__ ], $ resolver ->getPath ());
363+ yield [
364+ ['Command ' ],
365+ __DIR__ ,
366+ [__DIR__ .\DIRECTORY_SEPARATOR .'Command ' ],
367+ ];
345368 }
346369
347370 /**
371+ * @param array<string> $paths
372+ * @param string $expectedMessage
373+ *
348374 * @dataProvider provideEmptyPathCases
349375 */
350- public function testRejectInvalidPath (array $ paths )
376+ public function testRejectInvalidPath (array $ paths, $ expectedMessage )
351377 {
352378 $ resolver = $ this ->createConfigurationResolver (
353379 ['path ' => $ paths ],
@@ -356,16 +382,42 @@ public function testRejectInvalidPath(array $paths)
356382 );
357383
358384 $ this ->expectException (InvalidConfigurationException::class);
359- $ this ->expectExceptionMessage (' Invalid path: "". ' );
385+ $ this ->expectExceptionMessage ($ expectedMessage );
360386
361387 $ resolver ->getPath ();
362388 }
363389
364390 public function provideEmptyPathCases ()
365391 {
366- yield [['' ]];
367- yield [[__DIR__ , '' ]];
368- yield [['' , __DIR__ ]];
392+ yield [
393+ ['' ],
394+ 'Invalid path: "". ' ,
395+ ];
396+
397+ yield [
398+ [__DIR__ , '' ],
399+ 'Invalid path: "". ' ,
400+ ];
401+
402+ yield [
403+ ['' , __DIR__ ],
404+ 'Invalid path: "". ' ,
405+ ];
406+
407+ yield [
408+ [' ' ],
409+ 'Invalid path: " ". ' ,
410+ ];
411+
412+ yield [
413+ [__DIR__ , ' ' ],
414+ 'Invalid path: " ". ' ,
415+ ];
416+
417+ yield [
418+ [' ' , __DIR__ ],
419+ 'Invalid path: " ". ' ,
420+ ];
369421 }
370422
371423 public function testResolvePathWithFileThatIsExcludedDirectlyOverridePathMode ()
0 commit comments