InboxControllerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 71
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 15 1
A testShowAction() 0 20 1
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\MessagingBundle\Tests\Controller;
12
13
use Miliooo\MessagingBundle\Controller\InboxController;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
use Miliooo\Messaging\User\ParticipantInterface;
16
17
/**
18
 * Test file for the InboxController
19
 *
20
 * @author Michiel Boeckaert <[email protected]>
21
 */
22
class InboxControllerTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * The class under test
26
     *
27
     * @var InboxController
28
     */
29
    private $controller;
30
31
    /**
32
     * @var \PHPUnit_Framework_MockObject_MockObject
33
     */
34
    private $participantProvider;
35
36
    /**
37
     * @var \PHPUnit_Framework_MockObject_MockObject
38
     */
39
    private $templating;
40
41
    /**
42
     * @var \PHPUnit_Framework_MockObject_MockObject
43
     */
44
    private $inboxProvider;
45
46
    /**
47
     * @var ParticipantInterface
48
     */
49
    private $loggedInUser;
50
51
    /**
52
     * @var \PHPUnit_Framework_MockObject_MockObject
53
     */
54
    private $pagerfanta;
55
56
    public function setUp()
57
    {
58
        $this->loggedInUser = new ParticipantTestHelper(1);
59
        $this->pagerfanta = $this->getMockBuilder('Pagerfanta\Pagerfanta')->disableOriginalConstructor()->getMock();
60
        $this->inboxProvider =
61
            $this->getMock('Miliooo\Messaging\ThreadProvider\Folder\InboxProviderPagerFantaInterface');
62
63
        $this->participantProvider = $this->getMock('Miliooo\Messaging\User\ParticipantProviderInterface');
64
        $this->templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
65
        $this->controller = new InboxController(
66
            $this->participantProvider,
67
            $this->inboxProvider,
68
            $this->templating
69
        );
70
    }
71
72
    public function testShowAction()
73
    {
74
        $page = 2;
75
76
        $this->participantProvider
77
            ->expects($this->once())
78
            ->method('getAuthenticatedParticipant')
79
            ->will($this->returnvalue($this->loggedInUser));
80
81
        $this->inboxProvider->expects($this->once())
82
            ->method('getInboxThreadsPagerfanta')
83
            ->with($this->loggedInUser, $page)
84
            ->will($this->returnValue($this->pagerfanta));
85
86
        $this->templating->expects($this->once())
87
            ->method('renderResponse')
88
            ->with('MilioooMessagingBundle:Folders:inbox.html.twig', ['pagerfanta' => $this->pagerfanta]);
89
90
        $this->controller->showAction($page);
91
    }
92
}
93