Passed
Push — master ( c227df...528f97 )
by Petr
07:58
created

SupportTest::normalizeLinkProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace BasicTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_routed_paths\Support;
8
9
10
class SupportTest extends CommonTestClass
11
{
12
    /**
13
     * @param string $in
14
     * @param string[] $expected
15
     * @dataProvider nameFromTemplateProvider
16
     */
17
    public function testNameFromTemplate(string $in, array $expected): void
18
    {
19
        $this->assertEquals($expected, Support::moduleNameFromRequest($in));
20
    }
21
22
    public function nameFromTemplateProvider(): array
23
    {
24
        return [
25
            ['whatever-for-name', ['WhateverForName']],
26
            ['whatever--for--name', ['Whatever', 'For', 'Name']],
27
        ];
28
    }
29
30
    /**
31
     * @param string[] $in
32
     * @param string $expected
33
     * @dataProvider normalizeLinkProvider
34
     */
35
    public function testLinkModule(array $in, string $expected): void
36
    {
37
        $this->assertEquals($expected, Support::requestFromModuleName($in));
38
    }
39
40
    public function normalizeLinkProvider(): array
41
    {
42
        return [
43
            [['FooBar0Baz'], 'foo-bar0-baz'],
44
            [['Nope-Yep'], 'nope-yep'],
45
            [['Θεσσαλονίκη'], 'θεσσαλονίκη'], // not ASCII
46
            [['FooBar', 'Baz'], 'foo-bar--baz'],
47
        ];
48
    }
49
}
50