RouteCollectionTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 16
dl 0
loc 46
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanBeCounted() 0 7 1
A setUp() 0 3 1
A testCanBeIterated() 0 8 2
A testCanSetAndGetRoutes() 0 7 1
A testCanDetectNotSetRoute() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Router;
5
6
use PHPUnit\Framework\TestCase;
7
8
class RouteCollectionTest extends TestCase
9
{
10
    use CanMockHandler;
11
12
    /** @var RouteCollection */
13
    private $collection;
14
15
    public function setUp()
16
    {
17
        $this->collection = new RouteCollection();
18
    }
19
20
    public function testCanSetAndGetRoutes(): void
21
    {
22
        $route = new Route('GET', '/test', $this->mockHandler());
23
24
        $this->collection->set('test', $route);
25
26
        $this->assertEquals($route, $this->collection->get('test'));
27
    }
28
29
    public function testCanBeCounted(): void
30
    {
31
        $route = new Route('GET', '/test', $this->mockHandler());
32
33
        $this->collection->set('test', $route);
34
35
        $this->assertCount(1, $this->collection);
36
    }
37
38
    public function testCanBeIterated(): void
39
    {
40
        $route = new Route('GET', '/test', $this->mockHandler());
41
42
        $this->collection->set('test', $route);
43
44
        foreach ($this->collection as $r) {
45
            $this->assertEquals($route, $r);
46
        }
47
    }
48
49
    public function testCanDetectNotSetRoute(): void
50
    {
51
        $this->expectException(Error\RouteNotSetException::class);
52
53
        $this->collection->get('test');
54
    }
55
}
56