testGetInboxThreadsRepositoryReturnsNull()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

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