Completed
Push — master ( 0daa93...76ae44 )
by Raffael
01:40
created

RouterTest::testAppendRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Micro\Testsuite\Http;
3
4
use \PHPUnit\Framework\TestCase;
5
use \Micro\Http\Router;
6
use \Micro\Http\Router\Route;
7
use \Micro\Testsuite\MockLogger;
8
9
class RouterTest extends TestCase
10
{
11
    public function testInit()
12
    {
13
        $server = [
14
            'PATH_INFO' => 'index.php/api/my/path',
15
            'REQUEST_METHOD' => 'PUT',
16
        ];
17
18
        $router = new Router($server, new MockLogger());
19
        $this->assertEquals($router->getPath(), 'index.php/api/my/path');
20
        $this->assertEquals($router->getVerb(), 'put');
21
        return $router;
22
    }
23
24
    /**
25
     * @depends testInit
26
     */
27
    public function testVerb($router)
28
    {
29
        $router->setVerb('GET');
30
        $this->assertEquals($router->getVerb(), 'get');
31
    }
32
    
33
34
    /**
35
     * @depends testInit
36
     */
37
    public function testPath($router)
38
    {
39
        $router->setPath('index.php/api');
40
        $this->assertEquals($router->getPath(), 'index.php/api');
41
    }
42
    
43
44
    /**
45
     * @depends testInit
46
     */
47
    public function testAppendRoute($router)
48
    {
49
        $this->assertCount(0, $router->getRoutes());
50
        $router->appendRoute(new Route('/', 'Controller'));
51
        $this->assertCount(1, $router->getRoutes());
52
    }
53
    
54
55
    /**
56
     * @depends testInit
57
     */
58
    public function testClearRoutes($router)
59
    {
60
        $router->clearRoutingTable();
61
        $this->assertCount(0, $router->getRoutes());
62
    }
63
}
64