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\Tests\Notifications; |
12
|
|
|
|
13
|
|
|
use Miliooo\Messaging\Notifications\UnreadMessagesProviderDoctrine; |
14
|
|
|
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper; |
15
|
|
|
use Miliooo\Messaging\User\ParticipantInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Test file for Miliooo\Messaging\Notifications\UnreadMessagesProviderDoctrine |
19
|
|
|
* |
20
|
|
|
* @author Michiel Boeckaert <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class UnreadMessagesProviderDoctrineTest extends \PHPUnit_Framework_TestCase |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject |
26
|
|
|
*/ |
27
|
|
|
private $threadRepository; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The class under test. |
31
|
|
|
* |
32
|
|
|
* @var UnreadMessagesProviderDoctrine |
33
|
|
|
*/ |
34
|
|
|
private $unreadMessageProvider; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var ParticipantInterface |
38
|
|
|
*/ |
39
|
|
|
private $participant; |
40
|
|
|
|
41
|
|
|
public function setUp() |
42
|
|
|
{ |
43
|
|
|
$this->threadRepository = $this->getMock('Miliooo\Messaging\Repository\ThreadRepositoryInterface'); |
44
|
|
|
$this->unreadMessageProvider = new UnreadMessagesProviderDoctrine($this->threadRepository); |
45
|
|
|
$this->participant = new ParticipantTestHelper('1'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testInterface() |
49
|
|
|
{ |
50
|
|
|
$this->assertInstanceOf( |
51
|
|
|
'Miliooo\Messaging\Notifications\UnreadMessagesProviderInterface', |
52
|
|
|
$this->unreadMessageProvider |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testGetUnreadCount() |
57
|
|
|
{ |
58
|
|
|
$this->threadRepository->expects($this->once())->method('getUnreadMessageCountForParticipant') |
59
|
|
|
->with($this->participant) |
60
|
|
|
->will($this->returnValue(1)); |
61
|
|
|
$this->assertEquals(1, $this->unreadMessageProvider->getUnreadMessageCountForParticipant($this->participant)); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|