Passed
Push — master ( e8a992...1c9655 )
by Petr
02:20
created

PathTest::testCompactFrom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ProcessingTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_files\Processing\TPath;
8
9
10
class PathTest extends CommonTestClass
11
{
12
    /**
13
     * @param array<string> $from
14
     * @param string $to
15
     * @dataProvider transformProvider
16
     */
17
    public function testPaths(/** @scrutinizer ignore-unused */array $from, string $to): void
18
    {
19
        $lib = new XPath();
20
        $this->assertEmpty($lib->getPath());
21
        $lib->setPath($to);
22
        $this->assertEquals($to, $lib->getPath());
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
42
class XPath
43
{
44
    use TPath;
45
}
46