MessageMetaTest::testParticipantWorks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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 Milioo\Messaging\Tests\Model;
12
13
use Miliooo\Messaging\Model\MessageMeta;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
use Miliooo\Messaging\Model\MessageMetaInterface;
16
use Miliooo\Messaging\ValueObjects\ReadStatus;
17
18
/**
19
 * Test file for the message meta model
20
 *
21
 * @author Michiel Boeckaert <[email protected]>
22
 */
23
class MessageMetaTest extends \PHPUnit_Framework_TestCase
24
{
25
    /**
26
     * The class under test
27
     *
28
     * @var MessageMeta
29
     */
30
    private $messageMeta;
31
32
    public function setUp()
33
    {
34
        $this->messageMeta = $this->getMockForAbstractClass('Miliooo\Messaging\Model\MessageMeta');
35
    }
36
37
    public function testInterface()
38
    {
39
        $this->assertInstanceOf('Miliooo\Messaging\Model\MessageMetaInterface', $this->messageMeta);
40
    }
41
42
    public function testParticipantWorks()
43
    {
44
        $participant = new ParticipantTestHelper('participant');
45
        $this->messageMeta->setParticipant($participant);
46
        $this->assertSame($participant, $this->messageMeta->getParticipant());
47
    }
48
49
    public function testSetReadStatusUpdatesOldStatus()
50
    {
51
        //we set the status to read
52
        $readStatus = new ReadStatus(MessageMetaInterface::READ_STATUS_READ);
53
        $this->messageMeta->setReadStatus($readStatus);
54
        //the getReadStatus should be read
55
        $this->assertSame(MessageMetaInterface::READ_STATUS_READ, $this->messageMeta->getReadStatus());
56
        //the previous read status should still be never read //since we construct the message with status never read
57
        $this->assertNull($this->messageMeta->getPreviousReadStatus());
58
59
        //we set the new read status to marked_unread
60
        $readStatus = new ReadStatus(MessageMetaInterface::READ_STATUS_MARKED_UNREAD);
61
        $this->messageMeta->setReadStatus($readStatus);
62
        //the read status should be marked unread
63
        $this->assertSame(MessageMetaInterface::READ_STATUS_MARKED_UNREAD, $this->messageMeta->getReadStatus());
64
        //the previous status should now be read
65
        $this->assertSame(MessageMetaInterface::READ_STATUS_READ, $this->messageMeta->getPreviousReadStatus());
66
    }
67
68
    public function testMessageWorks()
69
    {
70
        $message = $this->getMock('Miliooo\Messaging\Model\MessageInterface');
71
        $this->messageMeta->setMessage($message);
72
        $this->assertSame($message, $this->messageMeta->getMessage());
73
    }
74
75
    public function testGetPreviousReadStatusDefaultsToNull()
76
    {
77
        $this->assertNull($this->messageMeta->getPreviousReadStatus());
78
    }
79
}
80