testGetOutBoxThreadsReturnsNullWhenNoResults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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\OutboxProvider;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
16
/**
17
 * Class OutboxProviderTest
18
 *
19
 * @author Michiel Boeckaert <[email protected]>
20
 */
21
class OutboxProviderTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * The class under test
25
     * @var OutboxProvider
26
     */
27
    private $outboxProvider;
28
    private $participant;
29
    /**
30
     * @var
31
     */
32
    private $threadRepository;
33
34
    public function setUp()
35
    {
36
        $this->threadRepository = $this->getMock('Miliooo\Messaging\Repository\ThreadRepositoryInterface');
37
        $this->participant = new ParticipantTestHelper(1);
38
        $this->outboxProvider = new OutboxProvider($this->threadRepository);
39
    }
40
41
    public function testInterface()
42
    {
43
        $this->assertInstanceOf(
44
            'Miliooo\Messaging\ThreadProvider\Folder\OutboxProviderInterface',
45
            $this->outboxProvider
46
        );
47
    }
48
49
    public function testGetOutBoxThreadsReturnsNullWhenNoResults()
50
    {
51
        $this->threadRepository->expects($this->once())->method('getOutboxThreadsForParticipant')
52
            ->with($this->participant)->will($this->returnValue(null));
53
54
        $result = $this->outboxProvider->getOutboxThreads($this->participant);
55
        $this->assertNull($result);
56
    }
57
58
    public function testGetOutBoThreadsReturnsThreadsWhenResults()
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('getOutboxThreadsForParticipant')
66
            ->with($participant)
67
            ->will($this->returnValue($arrayOfThreads));
68
69
        $this->assertEquals($arrayOfThreads, $this->outboxProvider->getOutboxThreads($participant));
70
    }
71
}
72