Passed
Push — master ( 528f97...5cd088 )
by Petr
03:27 queued 01:21
created

PathTest::testBasic1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.7
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_paths\PathsException;
8
use kalanis\kw_routed_paths\RoutedPath;
9
use kalanis\kw_routed_paths\Sources\Arrays;
10
11
12
class PathTest extends CommonTestClass
13
{
14
    /**
15
     * @throws PathsException
16
     */
17
    public function testBasic1(): void
18
    {
19
        $path = new RoutedPath(new Arrays(['user' => 'def', 'module' => 'jkl', 'mno' => 'pqr',]));
20
        $this->assertEmpty($path->getStaticPath());
21
        $this->assertEmpty($path->getVirtualPrefix());
22
        $this->assertEquals('def', $path->getUser());
23
        $this->assertEmpty($path->getLang());
24
        $this->assertEmpty($path->getPath());
25
        $this->assertEquals(['Jkl'], $path->getModule());
26
        $this->assertFalse($path->isSingle());
27
        $this->assertEquals([
28
            'user' => 'def',
29
            'lang' => '',
30
            'path' => [],
31
            'module' => ['Jkl'],
32
            'isSingle' => false,
33
            'staticPath' => '',
34
            'virtualPrefix' => '',
35
        ], $path->getArray());
36
    }
37
38
    /**
39
     * @throws PathsException
40
     */
41
    public function testBasic2(): void
42
    {
43
        $path = new RoutedPath(new Arrays(['lang' => 'bbdf', 'module' => 'jkl-uhb--tgfc-ebds', 'single' => '1', 'path' => 'fdfhg/djhjsfjk/hsdfgh/dfghdf/dfh']));
44
        $this->assertEmpty($path->getStaticPath());
45
        $this->assertEmpty($path->getVirtualPrefix());
46
        $this->assertEmpty($path->getUser());
47
        $this->assertEquals('bbdf', $path->getLang());
48
        $this->assertNotEmpty($path->getPath());
49
        $this->assertEquals(['JklUhb', 'TgfcEbds'], $path->getModule());
50
        $this->assertTrue($path->isSingle());
51
        $this->assertEquals([
52
            'user' => '',
53
            'lang' => 'bbdf',
54
            'path' => ['fdfhg', 'djhjsfjk', 'hsdfgh', 'dfghdf', 'dfh'],
55
            'module' => ['JklUhb', 'TgfcEbds'],
56
            'isSingle' => true,
57
            'staticPath' => '',
58
            'virtualPrefix' => '',
59
        ], $path->getArray());
60
    }
61
}
62