Completed
Push — new-user-bundle ( a512ca...38b344 )
by Wouter
62:04
created

MenuBuilderTest::testGettersAndSetters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace SumoCoders\FrameworkCoreBundle\Tests\Menu;
4
5
use SumoCoders\FrameworkCoreBundle\Menu\MenuBuilder;
6
7
class MenuBuilderTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var MenuBuilder
11
     */
12
    protected $menuBuilder;
13
14
    /**
15
     * @inherit
16
     */
17
    protected function setUp()
18
    {
19
        $this->menuBuilder = new MenuBuilder();
20
    }
21
22
    /**
23
     * @inherit
24
     */
25
    protected function tearDown()
26
    {
27
        $this->menuBuilder = null;
28
    }
29
30
    /**
31
     * @return \PHPUnit_Framework_MockObject_MockObject
32
     */
33
    protected function getEventDispatcher()
34
    {
35
        $eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
36
37
        return $eventDispatcher;
38
    }
39
40
    protected function getItem()
41
    {
42
        $item = $this->getMock('\Knp\Menu\ItemInterface');
43
44
        return $item;
45
    }
46
47
    /**
48
     * @return \PHPUnit_Framework_MockObject_MockObject
49
     */
50
    protected function getFactory()
51
    {
52
        $item = $this->getItem();
53
54
        /** @var \PHPUnit_Framework_MockObject_MockBuilder $factory */
55
        $factory = $this->getMock('\Knp\Menu\FactoryInterface');
56
        $factory->method('createItem')
57
            ->will(
58
                $this->returnValue(
59
                    $item
60
                )
61
            );
62
        $factory->method('getChildren')
63
            ->will(
64
                $this->returnValue(
65
                    array()
66
                )
67
            );
68
69
        return $factory;
70
    }
71
72
    /**
73
     * Test the getters and setters
74
     */
75
    public function testGettersAndSetters()
76
    {
77
        $eventDispatcher = $this->getEventDispatcher();
78
        $this->menuBuilder->setEventDispatcher($eventDispatcher);
79
        $this->assertEquals(
80
            $eventDispatcher,
81
            $this->menuBuilder->getEventDispatcher(),
82
            'eventDispatcher doesn\'t match'
83
        );
84
85
        $factory = $this->getFactory();
86
        $this->menuBuilder->setFactory($factory);
87
        $this->assertEquals(
88
            $factory,
89
            $this->menuBuilder->getFactory(),
90
            'factory doesn\'t match'
91
        );
92
    }
93
94
    public function testCreateMainMenu()
95
    {
96
        $this->markTestSkipped('I need time to mock this whole thing...');
97
98
        $this->menuBuilder->setFactory($this->getFactory());
99
        $this->menuBuilder->setEventDispatcher($this->getEventDispatcher());
100
101
        $this->menuBuilder->createMainMenu();
102
    }
103
}
104