Completed
Push — master ( 9b9083...4534a2 )
by Johannes
02:11
created

BlogEntryTest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testGetId() 0 4 1
A testGetTitle() 0 4 1
A testGetContent() 0 4 1
A testGetExcerpt() 0 4 1
A testGetExtend() 0 4 1
A testGetCreated() 0 4 1
A testGetUpdated() 0 4 1
A testIsDraft() 0 4 1
A testGetTags() 0 4 1
A testAddTag() 0 6 1
1
<?php
2
/**
3
 * Lichtenwallner  (https://lichtenwallner.at)
4
 *
5
 * @see https://github.com/jolicht/markdown-cms for the canonical source repository
6
 * @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
7
 * @copyright Copyright (c) Johannes Lichtenwallner
8
 */
9
declare(strict_types = 1);
10
namespace JolichtTest\MarkdownCms\ContentType;
11
12
use PHPUnit\Framework\TestCase;
13
use Jolicht\MarkdownCms\ContentType\BlogEntry;
14
use Jolicht\MarkdownCms\Taxonomy\Tag;
15
16
class BlogEntryTest extends TestCase
17
{
18
    private $blogEntry, $created, $updated, $content;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
19
20
    protected function setUp()
21
    {
22
        $this->content = 'testExcerpt' . PHP_EOL . BlogEntry::MORE_SEPARATOR . PHP_EOL . 'testExtend' . PHP_EOL;
23
24
        $this->created = new \DateTime();
25
        $this->updated = new \DateTime();
26
        $this->blogEntry = new BlogEntry('test-id', 'TestTitle', $this->content, $this->created, $this->updated, true);
27
    }
28
    public function testGetId()
29
    {
30
        $this->assertSame('test-id', $this->blogEntry->getId());
31
    }
32
33
    public function testGetTitle()
34
    {
35
        $this->assertSame('TestTitle', $this->blogEntry->getTitle());
36
    }
37
38
    public function testGetContent()
39
    {
40
        $this->assertSame($this->content, $this->blogEntry->getContent());
41
    }
42
43
    public function testGetExcerpt()
44
    {
45
        $this->assertSame('testExcerpt', $this->blogEntry->getExcerpt());
46
    }
47
48
    public function testGetExtend()
49
    {
50
        $this->assertSame('testExtend', $this->blogEntry->getExtend());
51
    }
52
53
    public function testGetCreated()
54
    {
55
        $this->assertSame($this->created, $this->blogEntry->getCreated());
56
    }
57
58
    public function testGetUpdated()
59
    {
60
        $this->assertSame($this->updated, $this->blogEntry->getUpdated());
61
    }
62
63
    public function testIsDraft()
64
    {
65
        $this->assertTrue($this->blogEntry->isDraft());
66
    }
67
68
    public function testGetTags()
69
    {
70
        $this->assertSame([], $this->blogEntry->getTags());
71
    }
72
73
    public function testAddTag()
74
    {
75
        $tag = new Tag('testId', 'testTitle');
76
        $this->blogEntry->addTag($tag);
77
        $this->assertSame([$tag], $this->blogEntry->getTags());
78
    }
79
}