Completed
Push — master ( d7143f...20bc41 )
by Mathieu
02:54
created

Library   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 40
rs 10
1
<?php
2
3
namespace Matks\MarkdownBlogBundle\Tests\Unit\Blog;
4
5
use Matks\MarkdownBlogBundle\Blog\Library as BaseLibrary;
6
use Matks\MarkdownBlogBundle\Tests\Unit\Blog\Post as PostTest;
7
use atoum;
8
9
class Library extends atoum
10
{
11
    public function testConstruct()
12
    {
13
        $library = new BaseLibrary([]);
14
15
        $this
16
            ->array($library->getAllPosts())
17
            ->isEmpty();
18
    }
19
20
    public function testConstructWithPosts()
21
    {
22
        $posts = PostTest::buildPostMocks(3);
23
24
        $library = new BaseLibrary($posts);
25
26
        $this
27
            ->array($library->getAllPosts())
28
            ->isEqualTo($posts);
29
    }
30
31
    public function testAddPost()
32
    {
33
        $library = new BaseLibrary([]);
34
35
        $this->boolean($library->isPostRegistered('A'))
36
             ->isFalse();
37
38
        $post = new \mock\Matks\MarkdownBlogBundle\Blog\Post(
39
            PostTest::getLoremIpsumFilepath(), 'A', '2016-01-02');
40
41
        $library->addPost($post);
42
43
        $this->boolean($library->isPostRegistered('A'))
44
             ->isTrue();
45
        $this->object($library->getPostByName('A'))
46
             ->isIdentiCalTo($post);
47
    }
48
}
49