File tree Expand file tree Collapse file tree 2 files changed +55
-4
lines changed Expand file tree Collapse file tree 2 files changed +55
-4
lines changed Original file line number Diff line number Diff line change @@ -14,22 +14,22 @@ private function __construct(string $path)
14
14
$ this ->path = $ path ;
15
15
}
16
16
17
- public function isAbsolute ()
17
+ public function isAbsolute (): bool
18
18
{
19
- return 0 === strpos ($ this ->path , ' / ' );
19
+ return Path:: isAbsolute ($ this ->path );
20
20
}
21
21
22
22
public function __toString ()
23
23
{
24
24
return $ this ->path ;
25
25
}
26
26
27
- public static function fromString ($ path )
27
+ public static function fromString ($ path ): FilePath
28
28
{
29
29
return new self ($ path );
30
30
}
31
31
32
- public static function fromParts (array $ parts )
32
+ public static function fromParts (array $ parts ): FilePath
33
33
{
34
34
$ path = implode ('/ ' , $ parts );
35
35
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Phpactor \ClassFileConverter \Tests \Unit \Domain ;
4
+
5
+ use PHPUnit \Framework \TestCase ;
6
+ use Phpactor \ClassFileConverter \Domain \FilePath ;
7
+
8
+ class FilePathTest extends TestCase
9
+ {
10
+ /**
11
+ * @dataProvider provideIsAbsolute
12
+ */
13
+ public function testIsAbsolute (string $ path , bool $ expected )
14
+ {
15
+ $ path = FilePath::fromString ($ path );
16
+ self ::assertEquals ($ expected , $ path ->isAbsolute ());
17
+ }
18
+
19
+ public function provideIsAbsolute ()
20
+ {
21
+ yield 'not absolute unix ' => [
22
+ 'foobar/barfoo ' ,
23
+ false ,
24
+ ];
25
+
26
+ yield 'absolute unix ' => [
27
+ '/foobar/barfoo ' ,
28
+ true ,
29
+ ];
30
+
31
+ yield 'absolute windows ' => [
32
+ 'c:\foobar\barfoo ' ,
33
+ true ,
34
+ ];
35
+
36
+ yield 'not absolute windows ' => [
37
+ 'foobar\barfoo ' ,
38
+ false ,
39
+ ];
40
+
41
+ yield 'absolute phar ' => [
42
+ 'phar:///barfoo ' ,
43
+ true
44
+ ];
45
+
46
+ yield 'not absolute phar ' => [
47
+ 'phar://barfoo ' ,
48
+ false ,
49
+ ];
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments