File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public static function isAbsPath(string $path): bool
4747 }
4848
4949 if (strpos ($ path , '/ ' ) === 0 || // linux/mac
50- 1 === preg_match ('#^[a-z]:[\/| \\\]{1} .+#i ' , $ path ) // windows
50+ 1 === preg_match ('#^[a-z]:[\/| \\\].+#i ' , $ path ) // windows
5151 ) {
5252 return true ;
5353 }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Toolkit \FsUtilTest ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Toolkit \FsUtil \FS ;
7+
8+ /**
9+ * class FsTest
10+ */
11+ class FsTest extends TestCase
12+ {
13+ public function testIsAbsPath (): void
14+ {
15+ $ tests = [
16+ '/tmp ' ,
17+ 'C:/tmp ' ,
18+ 'C: \\tmp ' ,
19+ 'C:\tmp ' ,
20+ "C: \\tmp " ,
21+ ];
22+
23+ foreach ($ tests as $ case ) {
24+ $ this ->assertTrue (FS ::isAbsPath ($ case ));
25+ $ this ->assertTrue (FS ::isAbsolutePath ($ case ));
26+ }
27+ }
28+
29+ public function testClearPharPath (): void
30+ {
31+ $ tests = [
32+ ['phar://E:/workenv/xxx/yyy/app.phar/web ' , 'E:/workenv/xxx/yyy/web ' ],
33+ ['phar:///workenv/xxx/yyy/app.phar/web ' , '/workenv/xxx/yyy/web ' ],
34+ ['E:/workenv/xxx/yyy/web ' , 'E:/workenv/xxx/yyy/web ' ],
35+ ['/workenv/xxx/yyy/web ' , '/workenv/xxx/yyy/web ' ],
36+ ];
37+
38+ foreach ($ tests as [$ test , $ want ]) {
39+ $ this ->assertSame ($ want , FS ::clearPharPath ($ test ));
40+ }
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments