Passed
Push — master ( 7a2f1a...90e94c )
by Petr
07:46
created

PathTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
c 0
b 0
f 0
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyExpand() 0 5 1
A transformProvider() 0 12 1
A testEmptyCompact() 0 5 1
A testExpandFrom() 0 4 1
1
<?php
2
3
namespace ExtrasTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_paths\Extras\PathTransform;
8
use kalanis\kw_paths\PathsException;
9
10
11
class PathTest extends CommonTestClass
12
{
13
    /**
14
     * @param array<string> $to
15
     * @param string $from
16
     * @throws PathsException
17
     * @dataProvider transformProvider
18
     */
19
    public function testExpandFrom(array $to, string $from): void
20
    {
21
        $lib = new PathTransform();
22
        $this->assertEquals($to, $lib->expandName($from));
23
    }
24
25
    public function transformProvider(): array
26
    {
27
        return [
28
            [['okmijnuhb', ], 'okmijnuhb', ],
29
            // just dirs
30
            [['wsx', 'edc', 'rfv', ], 'wsx' . DIRECTORY_SEPARATOR . 'edc' . DIRECTORY_SEPARATOR . 'rfv', ],
31
            // dir slash
32
            [['wsx/', 'edc', 'r f v', ], 'wsx\/' . DIRECTORY_SEPARATOR . 'edc' . DIRECTORY_SEPARATOR . 'r f v', ],
33
            // too many slashes
34
            [['wsx\\', 'e-dc', 'r&f&v', ], 'wsx\\\\' . DIRECTORY_SEPARATOR . 'e-dc' . DIRECTORY_SEPARATOR . 'r&f&v', ],
35
            // empty path
36
            [['', ], '', ],
37
        ];
38
    }
39
40
    /**
41
     * @throws PathsException
42
     */
43
    public function testEmptyCompact(): void
44
    {
45
        $lib = new PathTransform();
46
        $this->expectException(PathsException::class);
47
        $lib->compactName(['any', 'where'], '');
48
    }
49
50
    /**
51
     * @throws PathsException
52
     */
53
    public function testEmptyExpand(): void
54
    {
55
        $lib = new PathTransform();
56
        $this->expectException(PathsException::class);
57
        $lib->expandName('any/where', '');
58
    }
59
}
60