| Total Complexity | 15 |
| Total Lines | 268 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 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 |