Passed
Push — master ( 17d331...42ece1 )
by Alex
02:01
created

AddRouteUnitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAddGetRoute() 0 12 1
A actionRoute() 0 3 1
A testAddPostRoute() 0 12 1
1
<?php
2
namespace Mezon\Router\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Mezon\Router\Router;
6
7
class AddRouteUnitTest extends TestCase
8
{
9
10
    /**
11
     * Some action
12
     *
13
     * @return int
14
     */
15
    public function actionRoute(): int
16
    {
17
        return 1;
18
    }
19
20
    /**
21
     * Testing method addGetRoute
22
     */
23
    public function testAddGetRoute(): void
24
    {
25
        // setup
26
        $router = new Router();
27
        $route = 'route';
28
        RouterUnitTest::setRequestMethod('GET');
29
30
        // test body
31
        $router->addGetRoute($route, $this, 'actionRoute');
32
33
        // assertions
34
        $this->assertEquals(1, $router->callRoute($route));
35
    }
36
37
    /**
38
     * Testing method addPostRoute
39
     */
40
    public function testAddPostRoute(): void
41
    {
42
        // setup
43
        $router = new Router();
44
        $route = 'route';
45
        RouterUnitTest::setRequestMethod('POST');
46
47
        // test body
48
        $router->addPostRoute($route, $this, 'actionRoute');
49
50
        // assertions
51
        $this->assertEquals(1, $router->callRoute($route));
52
    }
53
}
54