DemoControllerUnitTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 61
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getController() 0 21 1
A testIndexAction() 0 4 1
A testLeftSidebarAction() 0 4 1
A testRightSidebarAction() 0 4 1
A testNoSidebarAction() 0 4 1
1
<?php
2
3
namespace Evheniy\HTML5VertiTemplateBundle\Tests\Controller;
4
5
use Evheniy\HTML5VertiTemplateBundle\Controller\DemoController;
6
7
/**
8
 * Class DemoControllerUnitTest
9
 *
10
 * @package Evheniy\HTML5VertiTemplateBundle\Tests\Controller
11
 */
12
class DemoControllerUnitTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @param string $view
16
     *
17
     * @return DemoController
18
     */
19
    protected function getController($view)
20
    {
21
        $controller = new DemoController();
22
        $response = $this->getMock('Symfony\Component\HttpFoundation\Response');
23
        $template = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
24
        $template
25
            ->expects($this->once())
26
            ->method("renderResponse")
27
            ->with($view, array(), null)
28
            ->will($this->returnValue($response));
29
30
        $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
31
        $container->expects($this->at(0))
32
            ->method("get")
33
            ->with("templating")
34
            ->will($this->returnValue($template));
35
36
        $controller->setContainer($container);
37
38
        return $controller;
39
    }
40
41
    /**
42
     *
43
     */
44
    public function testIndexAction()
45
    {
46
        $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $this->getController('HTML5VertiTemplateBundle:Demo:index.html.twig')->indexAction());
47
    }
48
49
    /**
50
     *
51
     */
52
    public function testLeftSidebarAction()
53
    {
54
        $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $this->getController('HTML5VertiTemplateBundle:Demo:left_sidebar.html.twig')->leftSidebarAction());
55
    }
56
57
    /**
58
     *
59
     */
60
    public function testRightSidebarAction()
61
    {
62
        $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $this->getController('HTML5VertiTemplateBundle:Demo:right_sidebar.html.twig')->rightSidebarAction());
63
    }
64
65
    /**
66
     *
67
     */
68
    public function testNoSidebarAction()
69
    {
70
        $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $this->getController('HTML5VertiTemplateBundle:Demo:no_sidebar.html.twig')->noSidebarAction());
71
    }
72
}