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

Post::testConstructBadFilepath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Matks\MarkdownBlogBundle\Tests\Unit\Blog;
4
5
use Matks\MarkdownBlogBundle\Blog\Post as BasePost;
6
use atoum;
7
8
class Post extends atoum
9
{
10
    public function testConstruct()
11
    {
12
        $post = new BasePost(self::getLoremIpsumFilepath(), 'a', '2016-01-01');
13
    }
14
15
    public function testConstructBadFilepath()
16
    {
17
        $this
18
            ->exception(
19
            function () {
20
                $border = new BasePost('random', 'a', 'b');
21
            }
22
            )->hasMessage('random is not a file');
23
    }
24
25
    public function testGetHtml()
26
    {
27
        $post = new BasePost(self::getShortFilepath(), 'a', '2016-01-01');
28
29
        $this
30
            ->string($post->getHtml())
31
            ->isEqualTo('<p>Short file</p>');
32
    }
33
34
    /**
35
     * @return string
36
     */
37
    public static function getLoremIpsumFilepath()
38
    {
39
        return __DIR__.'/../../data/lorem-ipsum.md';
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public static function getShortFilepath()
46
    {
47
        return __DIR__.'/../../data/short-file.md';
48
    }
49
50
    /**
51
     * @param int $count
52
     *
53
     * @return Post[]
54
     */
55
    public static function buildPostMocks($count)
56
    {
57
        $result = [];
58
        for ($i = 1; $i <= $count; ++$i) {
59
            $name = 'a'.$i;
60
61
            $result[$name] = new \mock\Matks\MarkdownBlogBundle\Blog\Post(
62
                static::getLoremIpsumFilepath(),
63
                $name,
64
                'b'
65
            );
66
        }
67
68
        return $result;
69
    }
70
}
71