Completed
Pull Request — master (#19)
by Wachter
07:23
created

CommentTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 22
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Bundle\CommentBundle\Tests\Unit\Entity;
13
14
use Sulu\Bundle\CommentBundle\Entity\Comment;
15
use Sulu\Bundle\CommentBundle\Entity\CommentInterface;
16
use Sulu\Bundle\CommentBundle\Entity\Thread;
17
18
class CommentTest extends \PHPUnit_Framework_TestCase
19
{
20
    public function testPublish()
21
    {
22
        $thread = new Thread('test', 1);
23
        $comment = new Comment(CommentInterface::STATE_UNPUBLISHED, $thread);
24
25
        $this->assertEquals(CommentInterface::STATE_UNPUBLISHED, $comment->getState());
26
        $this->assertFalse($comment->isPublished());
27
        $this->assertEquals(0, $thread->getCommentCount());
28
29
        $comment->publish();
30
        $this->assertEquals(CommentInterface::STATE_PUBLISHED, $comment->getState());
31
        $this->assertTrue($comment->isPublished());
32
        $this->assertEquals(1, $thread->getCommentCount());
33
34
        $comment->unpublish();
35
        $this->assertEquals(CommentInterface::STATE_UNPUBLISHED, $comment->getState());
36
        $this->assertFalse($comment->isPublished());
37
        $this->assertEquals(0, $thread->getCommentCount());
38
    }
39
}
40