testGetInboxThreadsRepositoryReturnsThreads()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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\Messaging\Tests\ThreadProvider\Folder;
12
13
use Miliooo\Messaging\ThreadProvider\Folder\ArchivedProvider;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
16
/**
17
 * Test file for the archived provider
18
 *
19
 * @author Michiel Boeckaert <[email protected]>
20
 */
21
class ArchivedProviderTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * The class under test
25
     *
26
     * @var ArchivedProvider
27
     */
28
    private $provider;
29
30
    /**
31
     * @var \PHPUnit_Framework_MockObject_MockObject
32
     */
33
    private $threadRepository;
34
35
    public function setUp()
36
    {
37
        $this->threadRepository = $this->getMock('Miliooo\Messaging\Repository\ThreadRepositoryInterface');
38
        $this->provider = new ArchivedProvider($this->threadRepository);
39
    }
40
41
    public function testInterface()
42
    {
43
        $this->assertInstanceOf('Miliooo\Messaging\ThreadProvider\Folder\ArchivedProviderInterface', $this->provider);
44
    }
45
46
    public function testGetInboxThreadsRepositoryReturnsNull()
47
    {
48
        $participant = new ParticipantTestHelper(1);
49
50
        $this->threadRepository->expects($this->once())
51
            ->method('getArchivedThreadsForParticipant')
52
            ->with($participant)
53
            ->will($this->returnValue(null));
54
55
        $this->assertNull($this->provider->getArchivedThreads($participant));
56
    }
57
58
    public function testGetInboxThreadsRepositoryReturnsThreads()
59
    {
60
        $participant = new ParticipantTestHelper(1);
61
        $thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
62
        $arrayOfThreads = [$thread];
63
64
        $this->threadRepository->expects($this->once())
65
            ->method('getArchivedThreadsForParticipant')
66
            ->with($participant)
67
            ->will($this->returnValue($arrayOfThreads));
68
69
        $this->assertEquals($arrayOfThreads, $this->provider->getArchivedThreads($participant));
70
    }
71
}
72