ThreadMetaTest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 83
rs 10
c 1
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A testDefaultStatusIsActive() 0 4 1
A testStatusWorks() 0 5 1
A setUp() 0 4 1
A testInterface() 0 4 1
A testIdWorks() 0 5 1
A testParticipantWorks() 0 6 1
A testStatusNeedsValidStatus() 0 4 1
A testLastParticipantMessageDateWorks() 0 6 1
A testLastMessageDateWorks() 0 6 1
A testThreadWorks() 0 6 1
A testUnreadMessageCountWorks() 0 9 1
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\Model;
12
13
use Miliooo\Messaging\Model\ThreadMeta;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
use Miliooo\Messaging\Model\ThreadMetaInterface;
16
17
/**
18
 * Description of ThreadMetaTest
19
 *
20
 * @author Michiel Boeckaert <[email protected]>
21
 */
22
class ThreadMetaTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * The class under test
26
     *
27
     * @var ThreadMeta
28
     */
29
    protected $threadMeta;
30
31
    public function setUp()
32
    {
33
        $this->threadMeta = $this->getMockForAbstractClass('Miliooo\Messaging\Model\ThreadMeta');
34
    }
35
36
    public function testInterface()
37
    {
38
        $this->assertInstanceOf('Miliooo\Messaging\Model\ThreadMetaInterface', $this->threadMeta);
39
    }
40
41
    public function testIdWorks()
42
    {
43
        $this->assertAttributeEquals(null, 'id', $this->threadMeta);
44
        $this->assertNull($this->threadMeta->getId());
45
    }
46
47
    public function testParticipantWorks()
48
    {
49
        $participant = new ParticipantTestHelper('participant');
50
        $this->threadMeta->setParticipant($participant);
51
        $this->assertSame($participant, $this->threadMeta->getParticipant());
52
    }
53
54
    public function testDefaultStatusIsActive()
55
    {
56
        $this->assertEquals(ThreadMetaInterface::STATUS_ACTIVE, $this->threadMeta->getStatus());
57
    }
58
59
    public function testStatusWorks()
60
    {
61
        $this->threadMeta->setStatus(ThreadMetaInterface::STATUS_ACTIVE);
62
        $this->assertEquals(ThreadMetaInterface::STATUS_ACTIVE, $this->threadMeta->getStatus());
63
    }
64
65
    /**
66
     * @expectedException \InvalidArgumentException
67
     * @expectedExceptionMessage Not a valid status
68
     */
69
    public function testStatusNeedsValidStatus()
70
    {
71
        $this->threadMeta->setStatus('foo');
72
    }
73
74
    public function testLastParticipantMessageDateWorks()
75
    {
76
        $dateTime = new \DateTime('2013-10-10 23:23:23');
77
        $this->threadMeta->setLastParticipantMessageDate($dateTime);
78
        $this->assertSame($dateTime, $this->threadMeta->getLastParticipantMessageDate());
79
    }
80
81
    public function testLastMessageDateWorks()
82
    {
83
        $dateTime = new \DateTime('2013-10-10 23:23:23');
84
        $this->threadMeta->setLastMessageDate($dateTime);
85
        $this->assertSame($dateTime, $this->threadMeta->getLastMessageDate());
86
    }
87
88
    public function testThreadWorks()
89
    {
90
        $thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
91
        $this->threadMeta->setThread($thread);
92
        $this->assertSame($thread, $this->threadMeta->getThread());
93
    }
94
95
    public function testUnreadMessageCountWorks()
96
    {
97
        //assert default value is zero
98
        $this->assertEquals(0, $this->threadMeta->getUnreadMessageCount());
99
100
        $unreadCount = 5;
101
        $this->threadMeta->setUnreadMessageCount($unreadCount);
102
        $this->assertSame($unreadCount, $this->threadMeta->getUnreadMessageCount());
103
    }
104
}
105