Passed
Push — master ( a4ddd3...82bd79 )
by Alex
06:44
created

BigSetOfRoutesTestClass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bigSetOfRoutesDataProvider() 0 8 1
A testBigSetOfRoutes() 0 16 2
1
<?php
2
declare(strict_types = 1);
3
namespace Mezon\Router\Tests\Base;
4
5
/**
6
 *
7
 * @psalm-suppress PropertyNotSetInConstructor
8
 */
9
abstract class BigSetOfRoutesTestClass extends StaticRoutesTestClass
10
{
11
12
    /**
13
     * Method provides testing data
14
     *
15
     * @return array testing data
16
     */
17
    public function bigSetOfRoutesDataProvider(): array
18
    {
19
        return [
20
            [
21
                99
22
            ],
23
            [
24
                101
25
            ]
26
        ];
27
    }
28
29
    /**
30
     * Testing method
31
     *
32
     * @param int $amount
33
     *            amount of routes
34
     * @dataProvider bigSetOfRoutesDataProvider
35
     */
36
    public function testBigSetOfRoutes(int $amount): void
37
    {
38
        // setup
39
        RouterUnitTestUtils::setRequestMethod('GET');
40
        $router = $this->getRouter();
41
        for ($i = 1; $i <= $amount; $i ++) {
42
            $router->addRoute('/param/[i:id]/' . $i, function () use ($i): int {
43
                return $i;
44
            });
45
        }
46
47
        // test body
48
        $result = (int) $router->callRoute('/param/1/' . $amount);
49
50
        // assertions
51
        $this->assertEquals($result, $amount);
52
    }
53
}
54