This repository was archived by the owner on Jul 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathTest.php
More file actions
36 lines (31 loc) · 1.48 KB
/
PathTest.php
File metadata and controls
36 lines (31 loc) · 1.48 KB
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
<?php
namespace Tests;
use Cli\Services\Paths;
class PathTest extends TestCase
{
public function test_resolve()
{
$cwd = getcwd();
$this->assertEquals('/my/path', Paths::resolve('/my/path/'));
$this->assertEquals('/my/path', Paths::resolve('\\my\\path'));
$this->assertEquals('/my/path', Paths::resolve('/my/path'));
$this->assertEquals('/my/path', Paths::resolve('/my/cats/../path'));
$this->assertEquals('/my/path', Paths::resolve('/my/cats/.././path'));
$this->assertEquals('/my/path', Paths::resolve('/my/path', '/root'));
$this->assertEquals('/root/my/path', Paths::resolve('my/path', '/root'));
$this->assertEquals('/my/path', Paths::resolve('../my/path', '/root'));
$this->assertEquals("{$cwd}/my/path", Paths::resolve('my/path'));
$this->assertEquals("{$cwd}", Paths::resolve(''));
}
public function test_join()
{
$this->assertEquals('/my/path', Paths::join('/my/', 'path'));
$this->assertEquals('/my/path', Paths::join('/my/', '/path'));
$this->assertEquals('/my/path', Paths::join('/my', 'path'));
$this->assertEquals('/my/path', Paths::join('/my', 'path/'));
$this->assertEquals('my/path/to/here', Paths::join('my', 'path', 'to', 'here'));
$this->assertEquals('my', Paths::join('my'));
$this->assertEquals('my/path', Paths::join('my//', '//path//'));
$this->assertEquals('/my/path', Paths::join('/my//', '\\path\\'));
}
}