Passed
Push — master ( 4cfdc5...37c7d0 )
by Alex
07:00
created

BigSetOfRoutesUnitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
c 0
b 0
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
namespace Mezon\Router\Tests\Standart;
3
4
use PHPUnit\Framework\TestCase;
5
use Mezon\Router\Router;
6
use Mezon\Router\Tests\Base\RouterUnitTestUtils;
7
8
/**
9
 * @psalm-suppress PropertyNotSetInConstructor
10
 */
11
class BigSetOfRoutesUnitTest extends TestCase
12
{
13
14
    /**
15
     * Method provides testing data
16
     *
17
     * @return array testing data
18
     */
19
    public function bigSetOfRoutesDataProvider(): array
20
    {
21
        return [
22
            [
23
                99
24
            ],
25
            [
26
                101
27
            ]
28
        ];
29
    }
30
31
    /**
32
     * Testing method
33
     *
34
     * @param int $amount
35
     *            amount of routes
36
     * @dataProvider bigSetOfRoutesDataProvider
37
     */
38
    public function testBigSetOfRoutes(int $amount): void
39
    {
40
        // setup
41
        RouterUnitTestUtils::setRequestMethod('GET');
42
        $router = new Router();
43
        for ($i = 1; $i <= $amount; $i ++) {
44
            $router->addRoute('/param/[i:id]/' . $i, function () use ($i): int {
45
                return $i;
46
            });
47
        }
48
49
        // test body
50
        $result = $router->callRoute('/param/1/' . $amount);
51
52
        // assertions
53
        $this->assertEquals($amount, $result);
54
    }
55
}
56