Test Failed
Pull Request — master (#32)
by Anatoly
04:53
created

RouteCollectionTest   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 268
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 159
dl 0
loc 268
rs 10
c 0
b 0
f 0
wmc 15
1
<?php declare(strict_types=1);
2
3
namespace Sunrise\Http\Router\Tests;
4
5
/**
6
 * Import classes
7
 */
8
use PHPUnit\Framework\TestCase;
9
use Sunrise\Http\Router\RouteCollection;
10
use Sunrise\Http\Router\RouteCollectionInterface;
11
use ArrayIterator;
12
use IteratorAggregate;
13
use Countable;
14
15
/**
16
 * RouteCollectionTest
17
 */
18
class RouteCollectionTest extends TestCase
19
{
20
21
    /**
22
     * @return void
23
     */
24
    public function testConstructor() : void
25
    {
26
        $collection = new RouteCollection();
27
28
        $this->assertInstanceOf(RouteCollectionInterface::class, $collection);
29
        $this->assertInstanceOf(IteratorAggregate::class, $collection);
30
        $this->assertInstanceOf(Countable::class, $collection);
31
    }
32
33
    /**
34
     * @return void
35
     */
36
    public function testAdd() : void
37
    {
38
        $routes = [
39
            new Fixture\TestRoute(),
40
            new Fixture\TestRoute(),
41
            new Fixture\TestRoute(),
42
        ];
43
44
        $collection = new RouteCollection();
45
46
        $collection->add(...$routes);
47
48
        $this->assertSame($routes, $collection->all());
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    public function testCount() : void
55
    {
56
        $routes = [
57
            new Fixture\TestRoute(),
58
            new Fixture\TestRoute(),
59
            new Fixture\TestRoute(),
60
        ];
61
62
        $collection = new RouteCollection();
63
64
        $this->assertCount(0, $collection);
65
66
        $collection->add(...$routes);
67
68
        $this->assertCount(3, $collection);
69
    }
70
71
    /**
72
     * @return void
73
     */
74
    public function testIterator() : void
75
    {
76
        $collection = new RouteCollection();
77
78
        $this->assertInstanceOf(ArrayIterator::class, $collection->getIterator());
79
    }
80
}
81