|
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
|
|
|
|