OutboxControllerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 15 1
A testShowAction() 0 19 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\OutboxController;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
16
/**
17
 * Test file for outboxcontroller.
18
 *
19
 * @author Michiel Boeckaert <[email protected]>
20
 */
21
class OutboxControllerTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * The class under test
25
     *
26
     * @var OutboxController
27
     */
28
    private $controller;
29
30
    /**
31
     * @var \PHPUnit_Framework_MockObject_MockObject
32
     */
33
    private $participantProvider;
34
35
    /**
36
     * @var \PHPUnit_Framework_MockObject_MockObject
37
     */
38
    private $templating;
39
40
    /**
41
     * @var \PHPUnit_Framework_MockObject_MockObject
42
     */
43
    private $outboxProvider;
44
    private $loggedInUser;
45
    private $pagerfanta;
46
47
    public function setup()
48
    {
49
        $this->loggedInUser = new ParticipantTestHelper(1);
50
        $this->threads = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
51
        $this->outboxProvider =
52
            $this->getMock('Miliooo\Messaging\ThreadProvider\Folder\OutboxProviderPagerFantaInterface');
53
        $this->pagerfanta = $this->getMockBuilder('Pagerfanta\Pagerfanta')->disableOriginalConstructor()->getMock();
54
        $this->participantProvider = $this->getMock('Miliooo\Messaging\User\ParticipantProviderInterface');
55
        $this->templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
56
        $this->controller = new OutboxController(
57
            $this->templating,
58
            $this->outboxProvider,
59
            $this->participantProvider
60
        );
61
    }
62
63
    public function testShowAction()
64
    {
65
        $page = 1;
66
        $this->participantProvider
67
            ->expects($this->once())
68
            ->method('getAuthenticatedParticipant')
69
            ->will($this->returnvalue($this->loggedInUser));
70
71
        $this->outboxProvider->expects($this->once())
72
            ->method('getOutboxThreadsPagerfanta')
73
            ->with($this->loggedInUser, $page)
74
            ->will($this->returnValue($this->pagerfanta));
75
76
        $this->templating->expects($this->once())
77
            ->method('renderResponse')
78
            ->with('MilioooMessagingBundle:Folders:outbox.html.twig', ['pagerfanta' => $this->pagerfanta]);
79
80
        $this->controller->showAction($page);
81
    }
82
}
83