Test Failed
Push — master ( 0ee32e...41c938 )
by Dan
07:10
created

DispatcherTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testWithNamespace() 0 7 1
A testWithNamespaces() 0 16 1
1
<?php
2
3
namespace Tests\Router\Dispatcher;
4
5
use Ds\Router\Dispatcher\Dispatcher;
6
use Tests\Router\Helpers\Reflection;
7
8
/**
9
 * Class DispatcherTest
10
 * @package Tests\Router\Dispatcher
11
 */
12
class DispatcherTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var Dispatcher
16
     */
17
    public $dispatcher;
18
19
    public function setUp()
20
    {
21
        $options = [];
22
        $this->dispatcher = new Dispatcher($options);
23
    }
24
25
    public function testWithNamespace()
26
    {
27
        $ns = 'myNamespace';
28
        $dispatcher = $this->dispatcher->withNamespace($ns);
29
        $addedNamespaces = Reflection::getProperty(Dispatcher::class, 'namespaces', $dispatcher);
30
        $this->assertEquals([$ns => $ns], $addedNamespaces);
31
    }
32
33
    public function testWithNamespaces()
34
    {
35
        $namespaces = [
36
            '\my\namespace','another','one\more'
37
        ];
38
39
        $expected = [
40
            $namespaces[0] => $namespaces[0],
41
            $namespaces[1] => $namespaces[1],
42
            $namespaces[2] => $namespaces[2]
43
        ];
44
45
        $dispatcher = $this->dispatcher->withNamespaces($namespaces);
46
        $addedNamespaces = Reflection::getProperty(Dispatcher::class, 'namespaces', $dispatcher);
47
        $this->assertEquals($expected, $addedNamespaces);
48
    }
49
}
50