Passed
Push — master ( 22c5d8...61847e )
by Alex
07:43
created

NonAsciiCharsUnitTestClass::testNonAsciiParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 16
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
namespace Mezon\Router\Tests\Base;
4
5
/**
6
 *
7
 * @psalm-suppress PropertyNotSetInConstructor
8
 */
9
abstract class NonAsciiCharsUnitTestClass extends BaseRouterUnitTestClass
10
{
11
12
    /**
13
     * Some action
14
     *
15
     * @return int
16
     */
17
    public function actionRoute(): int
18
    {
19
        return 1;
20
    }
21
22
    /**
23
     * Testing callig non-ASCII char route
24
     */
25
    public function testCallNonAsciiCharRoute(): void
26
    {
27
        // setup
28
        $router = $this->getRouter();
29
        RouterUnitTestUtils::setRequestMethod('GET');
30
31
        // test body
32
        $router->addGetRoute('кириллический-урл', $this, 'actionRoute');
33
34
        // assertions
35
        $this->assertEquals(1, $router->callRoute(urlencode('кириллический-урл')));
36
    }
37
38
    /**
39
     * Testing method
40
     */
41
    public function testNonAsciiParams(): void
42
    {
43
        // setup
44
        $router = $this->getRouter();
45
        RouterUnitTestUtils::setRequestMethod('GET');
46
47
        // test body
48
        $router->addRoute(
49
            'кириллический-урл/[s:non-ascii-param]',
50
            function (string $route, array $params): string {
51
                return $params['non-ascii-param'];
52
            },
53
            'GET');
54
55
        // assertions
56
        $this->assertEquals('ни разу не ASCII - 日本語', $router->callRoute(urlencode('кириллический-урл/ни разу не ASCII - 日本語')));
57
    }
58
}
59