Passed
Branch master (7a2f1a)
by Petr
03:10
created

PathTest::testArrayPath3()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_paths\ArrayPath;
8
use kalanis\kw_paths\Path;
9
use kalanis\kw_paths\PathsException;
10
11
12
class PathTest extends CommonTestClass
13
{
14
    public function testBasic(): void
15
    {
16
        $path = new Path();
17
        $path->setData(['user'=>'def','module'=>'jkl','mno'=>'pqr',]);
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::setData() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

17
        /** @scrutinizer ignore-deprecated */ $path->setData(['user'=>'def','module'=>'jkl','mno'=>'pqr',]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
18
        $path->setDocumentRoot('/abc/def/ghi/jkl');
19
        $path->setPathToSystemRoot('../mno/pqr');
20
        $this->assertEquals(implode(DIRECTORY_SEPARATOR, ['', 'abc', 'def', 'ghi', 'jkl']), $path->getDocumentRoot());
21
        $this->assertEquals(implode(DIRECTORY_SEPARATOR, ['..', 'mno', 'pqr']), $path->getPathToSystemRoot());
22
        $this->assertEmpty($path->getStaticalPath());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getStaticalPath() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

22
        $this->assertEmpty(/** @scrutinizer ignore-deprecated */ $path->getStaticalPath());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
23
        $this->assertEmpty($path->getVirtualPrefix());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getVirtualPrefix() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

23
        $this->assertEmpty(/** @scrutinizer ignore-deprecated */ $path->getVirtualPrefix());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
24
        $this->assertEquals('def', $path->getUser());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getUser() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

24
        $this->assertEquals('def', /** @scrutinizer ignore-deprecated */ $path->getUser());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
25
        $this->assertEmpty($path->getLang());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getLang() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

25
        $this->assertEmpty(/** @scrutinizer ignore-deprecated */ $path->getLang());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
26
        $this->assertEmpty($path->getPath());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getPath() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

26
        $this->assertEmpty(/** @scrutinizer ignore-deprecated */ $path->getPath());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
27
        $this->assertEquals('jkl', $path->getModule());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::getModule() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

27
        $this->assertEquals('jkl', /** @scrutinizer ignore-deprecated */ $path->getModule());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
28
        $this->assertEmpty($path->isSingle());
0 ignored issues
show
Deprecated Code introduced by
The function kalanis\kw_paths\Path::isSingle() has been deprecated: since 2023-04-04 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

28
        $this->assertEmpty(/** @scrutinizer ignore-deprecated */ $path->isSingle());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
29
    }
30
31
    /**
32
     * @throws PathsException
33
     */
34
    public function testArrayPath1(): void
35
    {
36
        $path = new ArrayPath();
37
        $path->setString(implode(DIRECTORY_SEPARATOR, ['', 'abc', '..', 'def.ghi', '.', 'jkl', '', 'mno.pqr']));
38
        $this->assertEquals(implode(DIRECTORY_SEPARATOR, ['abc', 'def.ghi', 'jkl', 'mno.pqr']), (string) $path);
39
        $this->assertEquals('mno.pqr', $path->getFileName());
40
        $this->assertEquals(implode(DIRECTORY_SEPARATOR, ['abc', 'def.ghi', 'jkl']), $path->getStringDirectory());
41
        $this->assertEquals(implode(DIRECTORY_SEPARATOR, ['abc', 'def.ghi', 'jkl', 'mno.pqr']), $path->getString());
42
        $this->assertEquals(['abc', 'def.ghi', 'jkl'], $path->getArrayDirectory());
43
        $this->assertEquals(['abc', 'def.ghi', 'jkl', 'mno.pqr'], $path->getArray());
44
    }
45
46
    /**
47
     * @throws PathsException
48
     */
49
    public function testArrayPath2(): void
50
    {
51
        $path = new ArrayPath();
52
        $path->setArray(['', '.', '..', '.', '']); // content NOPE!
53
        $this->assertEquals('', (string) $path);
54
        $this->assertEquals('', $path->getFileName());
55
        $this->assertEquals('', $path->getStringDirectory());
56
        $this->assertEquals('', $path->getString());
57
        $this->assertEquals([], $path->getArrayDirectory());
58
        $this->assertEquals([], $path->getArray());
59
    }
60
61
    /**
62
     * @throws PathsException
63
     */
64
    public function testArrayPath3(): void
65
    {
66
        $path = new ArrayPath();
67
        $path->setString('abcdef');
68
        $this->assertEquals('abcdef', (string) $path);
69
        $this->assertEquals('abcdef', $path->getFileName());
70
        $this->assertEquals('', $path->getStringDirectory());
71
        $this->assertEquals('abcdef', $path->getString());
72
        $this->assertEquals([], $path->getArrayDirectory());
73
        $this->assertEquals(['abcdef'], $path->getArray());
74
    }
75
}
76