@@ -16,39 +16,52 @@ class FilePathFormatterTest extends MagentoTestCase
1616 /**
1717 * Test file format.
1818 *
19- * @param string $path
20- * @param bool $withTrailingSeparator
19+ * @param string $path
20+ * @param bool|null $withTrailingSeparator
2121 * @param string|null $expectedPath
2222 *
2323 * @return void
2424 * @throws TestFrameworkException
2525 * @dataProvider formatDataProvider
2626 */
27- public function testFormat (string $ path , bool $ withTrailingSeparator , ?string $ expectedPath ): void
27+ public function testFormat (string $ path , ? bool $ withTrailingSeparator , ?string $ expectedPath ): void
2828 {
2929 if (null !== $ expectedPath ) {
30+ if ($ withTrailingSeparator === null ) {
31+ $ this ->assertEquals ($ expectedPath , FilePathFormatter::format ($ path ));
32+ return ;
33+ }
3034 $ this ->assertEquals ($ expectedPath , FilePathFormatter::format ($ path , $ withTrailingSeparator ));
3135 } else {
3236 // Assert no exception
33- FilePathFormatter::format ($ path , $ withTrailingSeparator );
37+ if ($ withTrailingSeparator === null ) {
38+ FilePathFormatter::format ($ path );
39+ } else {
40+ FilePathFormatter::format ($ path , $ withTrailingSeparator );
41+ }
3442 $ this ->assertTrue (true );
3543 }
3644 }
3745
3846 /**
3947 * Test file format with exception.
4048 *
41- * @param string $path
42- * @param bool $withTrailingSeparator
49+ * @param string $path
50+ * @param bool|null $withTrailingSeparator
4351 *
4452 * @return void
4553 * @throws TestFrameworkException
4654 * @dataProvider formatExceptionDataProvider
4755 */
48- public function testFormatWithException (string $ path , bool $ withTrailingSeparator ): void
56+ public function testFormatWithException (string $ path , ? bool $ withTrailingSeparator ): void
4957 {
5058 $ this ->expectException (TestFrameworkException::class);
5159 $ this ->expectExceptionMessage ("Invalid or non-existing file: $ path \n" );
60+
61+ if ($ withTrailingSeparator === null ) {
62+ FilePathFormatter::format ($ path );
63+ return ;
64+ }
5265 FilePathFormatter::format ($ path , $ withTrailingSeparator );
5366 }
5467
@@ -63,14 +76,14 @@ public function formatDataProvider(): array
6376 $ path2 = $ path1 . DIRECTORY_SEPARATOR ;
6477
6578 return [
66- [$ path1 , false , $ path1 ],
79+ [$ path1 , null , $ path2 ],
6780 [$ path1 , false , $ path1 ],
6881 [$ path1 , true , $ path2 ],
69- [$ path2 , false , $ path1 ],
82+ [$ path2 , null , $ path2 ],
7083 [$ path2 , false , $ path1 ],
7184 [$ path2 , true , $ path2 ],
72- [__DIR__ . DIRECTORY_SEPARATOR . basename (__FILE__ ), false , __FILE__ ],
73- ['' , false , null ] // Empty string is valid
85+ [__DIR__ . DIRECTORY_SEPARATOR . basename (__FILE__ ), null , __FILE__ . DIRECTORY_SEPARATOR ],
86+ ['' , null , null ] // Empty string is valid
7487 ];
7588 }
7689
@@ -82,8 +95,8 @@ public function formatDataProvider(): array
8295 public function formatExceptionDataProvider (): array
8396 {
8497 return [
85- ['abc ' , false ],
86- ['X://some\dir/@ ' , false ]
98+ ['abc ' , null ],
99+ ['X://some\dir/@ ' , null ]
87100 ];
88101 }
89102}
0 commit comments