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

AddRouteUnitTest::testAddPostRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 12
rs 10
c 1
b 0
f 0
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