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

LinkTest::testLinkPrefix()   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 5
dl 0
loc 4
rs 10
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_routed_paths\Linking;
8
9
10
class LinkTest extends CommonTestClass
11
{
12
    /**
13
     * @param string[] $path
14
     * @param string[] $module
15
     * @param bool $asSingle
16
     * @param string $user
17
     * @param string $expected
18
     * @dataProvider linkMakeProvider
19
     */
20
    public function testLinkMake(array $path, array $module, bool $asSingle, string $user, string $expected): void
21
    {
22
        $lib = new Linking\Link();
23
        $this->assertEquals($expected, $lib->link($path, $module, $asSingle, $user));
24
    }
25
26
    /**
27
     * @param string[] $path
28
     * @param string[] $module
29
     * @param bool $asSingle
30
     * @param string $user
31
     * @param string $expected
32
     * @dataProvider linkMakeProvider
33
     */
34
    public function testLinkPrefix(array $path, array $module, bool $asSingle, string $user, string $expected): void
35
    {
36
        $lib = new Linking\Link('/some-prefix');
37
        $this->assertEquals('some-prefix/' . $expected, $lib->link($path, $module, $asSingle, $user));
38
    }
39
40
    /**
41
     * @param string[] $path
42
     * @param string[] $module
43
     * @param bool $asSingle
44
     * @param string $user
45
     * @param string $expected
46
     * @dataProvider linkMakeProvider
47
     */
48
    public function testLinkExt(array $path, array $module, bool $asSingle, string $user, string $expected): void
49
    {
50
        $lib = new Linking\External(new Linking\Link('/some-prefix'), ['foo', 'bar'], $user);
51
        $this->assertEquals('some-prefix/' . $expected, $lib->link($path, $module, $asSingle));
52
    }
53
54
    public function linkMakeProvider(): array
55
    {
56
        return [
57
            [[], [], true, '', ''],
58
            [['FooBar', 'Baz'], [], true, '', 'FooBar/Baz'],
59
            [[], ['FooBar', 'Baz'], true, '', 'ms:foo-bar--baz'],
60
            [[], [], true, 'anyone', 'u:anyone'],
61
            [['FooBar', 'Baz'], ['FooBar', 'Baz'], false, 'anyone', 'm:foo-bar--baz/u:anyone/FooBar/Baz'],
62
63
//            [[], [], true, '', ''],
64
        ];
65
    }
66
}
67