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

DisparcherTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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