-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPathTest.php
46 lines (40 loc) · 1.03 KB
/
PathTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php declare(strict_types=1);
namespace Toolkit\FsUtilTest;
use PHPUnit\Framework\TestCase;
use Toolkit\FsUtil\Path;
/**
* class PathTest
*
* @author inhere
*/
class PathTest extends TestCase
{
public function testPath_isAbs(): void
{
$tests = [
'/tmp',
'C:/tmp',
'C:\\tmp',
'C:\tmp',
"C:\\tmp",
];
foreach ($tests as $case) {
$this->assertTrue(Path::isAbs($case));
$this->assertTrue(Path::isAbsolute($case));
}
}
public function testFormat(): void
{
$tests = [
'/path/to/tmp' => '/path/to/tmp',
'C:\tmp' => 'C:/tmp',
'C:/path/to/dir' => 'C:/path/to/dir',
'C:\\path\\to\\dir' => 'C:/path/to/dir',
"path\\to\\dir" => 'path/to/dir',
];
foreach ($tests as $case => $expect) {
$this->assertSame($expect, Path::format($case, false));
$this->assertSame($expect . '/', Path::format($case));
}
}
}