ArchivedControllerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 67
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\Messaging\User\ParticipantInterface;
14
use Miliooo\MessagingBundle\Controller\ArchivedController;
15
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
16
17
/**
18
 * Test file for the ArchivedController
19
 *
20
 * @author Michiel Boeckaert <[email protected]>
21
 */
22
class ArchivedControllerTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * The class under test
26
     *
27
     * @var ArchivedController
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 $archivedProvider;
45
46
    /**
47
     * @var ParticipantInterface
48
     */
49
    private $loggedInUser;
50
    private $pagerfanta;
51
52
    public function setUp()
53
    {
54
        $this->loggedInUser = new ParticipantTestHelper(1);
55
        $this->pagerfanta = $this->getMockBuilder('Pagerfanta\Pagerfanta')->disableOriginalConstructor()->getMock();
56
        $this->archivedProvider =
57
            $this->getMock('Miliooo\Messaging\ThreadProvider\Folder\ArchivedProviderPagerFantaInterface');
58
59
        $this->participantProvider = $this->getMock('Miliooo\Messaging\User\ParticipantProviderInterface');
60
        $this->templating = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
61
        $this->controller = new ArchivedController(
62
            $this->participantProvider,
63
            $this->archivedProvider,
64
            $this->templating
65
        );
66
    }
67
68
    public function testShowAction()
69
    {
70
        $page = 2;
71
72
        $this->participantProvider
73
            ->expects($this->once())
74
            ->method('getAuthenticatedParticipant')
75
            ->will($this->returnvalue($this->loggedInUser));
76
77
        $this->archivedProvider->expects($this->once())
78
            ->method('getArchivedThreadsPagerfanta')
79
            ->with($this->loggedInUser, $page)
80
            ->will($this->returnValue($this->pagerfanta));
81
82
        $this->templating->expects($this->once())
83
            ->method('renderResponse')
84
            ->with('MilioooMessagingBundle:Folders:archived.html.twig', ['pagerfanta' => $this->pagerfanta]);
85
86
        $this->controller->showAction($page);
87
    }
88
}
89