Passed
Push — master ( c6a6de...ed87d4 )
by Kirill
02:46
created

ConversionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
eloc 23
c 1
b 1
f 0
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalizeFilePath() 0 6 1
A testNormalizeDirectoryPath() 0 6 1
A testRelativePath() 0 27 1
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Files;
13
14
use Spiral\Files\Files;
15
16
class ConversionTest extends TestCase
17
{
18
    public function testNormalizeFilePath(): void
19
    {
20
        $files = new Files();
21
22
        $this->assertSame('/abc/file.name', $files->normalizePath('/abc\\file.name'));
23
        $this->assertSame('/abc/file.name', $files->normalizePath('\\abc//file.name'));
24
    }
25
26
    public function testNormalizeDirectoryPath(): void
27
    {
28
        $files = new Files();
29
30
        $this->assertSame('/abc/dir/', $files->normalizePath('\\abc/dir', true));
31
        $this->assertSame('/abc/dir/', $files->normalizePath('\\abc//dir', true));
32
    }
33
34
    public function testRelativePath(): void
35
    {
36
        $files = new Files();
37
38
        $this->assertSame(
39
            'some-filename.txt',
40
            $files->relativePath('/abc/some-filename.txt', '/abc')
41
        );
42
43
        $this->assertSame(
44
            '../some-filename.txt',
45
            $files->relativePath('/abc/../some-filename.txt', '/abc')
46
        );
47
48
        $this->assertSame(
49
            '../../some-filename.txt',
50
            $files->relativePath('/abc/../../some-filename.txt', '/abc')
51
        );
52
53
        $this->assertSame(
54
            './some-filename.txt',
55
            $files->relativePath('/abc/some-filename.txt', '/abc/..')
56
        );
57
58
        $this->assertSame(
59
            '../some-filename.txt',
60
            $files->relativePath('/abc/some-filename.txt', '/abc/../..')
61
        );
62
    }
63
}
64