RouterUtilsUnitTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 15
c 1
b 0
f 1
dl 0
loc 61
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCallableDescription() 0 4 1
A getCallableDescriptionDataProvider() 0 26 1
A testMethodNameToRouteConversion() 0 7 1
1
<?php
2
declare(strict_types = 1);
3
namespace Mezon\Router\Tests\Standart;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 *
9
 * @psalm-suppress PropertyNotSetInConstructor
10
 */
11
class RouterUtilsUnitTest extends TestCase
12
{
13
14
    /**
15
     * Datapdovider for the test testGetCallableDescription
16
     *
17
     * @return array testing data
18
     */
19
    public function getCallableDescriptionDataProvider(): array
20
    {
21
        return [
22
            [
23
                'string-processor',
24
                'string-processor'
25
            ],
26
            [
27
                [
28
                    $this,
29
                    'getCallableDescriptionDataProvider'
30
                ],
31
                get_class($this) . '::getCallableDescriptionDataProvider'
32
            ],
33
            [
34
                [
35
                    'class-name',
36
                    'static-method-name'
37
                ],
38
                'class-name::static-method-name'
39
            ],
40
            [
41
                [
42
                    'string-processor'
43
                ],
44
                'a:1:{i:0;s:16:"string-processor";}'
45
            ]
46
        ];
47
    }
48
49
    /**
50
     * Testing getCallableDescription method
51
     *
52
     * @param mixed $callable
53
     * @param string $result
54
     * @dataProvider getCallableDescriptionDataProvider
55
     */
56
    public function testGetCallableDescription($callable, string $result): void
57
    {
58
        // test body and assertions
59
        $this->assertEquals($result, \Mezon\Router\Utils::getCallableDescription($callable));
60
    }
61
62
    /**
63
     * Testing convertMethodNameToRoute
64
     */
65
    public function testMethodNameToRouteConversion(): void
66
    {
67
        // test body
68
        $result = \Mezon\Router\Utils::convertMethodNameToRoute('actionSomeRouter');
69
70
        // assertions
71
        $this->assertEquals('some-router', $result);
72
    }
73
}
74