Test Failed
Push — master ( 3e96d2...d4b731 )
by Dan
06:30
created

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