Completed
Push — master ( c02fce...0001a8 )
by Johannes
03:23
created

EntryParserTest::testGetConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\EntryParser;
14
use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser;
15
use Jolicht\MarkdownCms\ContentType\ContentCreator;
16
use Jolicht\MarkdownCms\Markdown\MarkdownDocument;
17
use Jolicht\MarkdownCms\ContentType\ContentTypeInterface;
18
19
class EntryParserTest extends TestCase
20
{
21
    private $parser, $mdDocumentParser, $contentCreator, $config;
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...
22
23
    protected function setUp()
24
    {
25
        $this->config = [
26
            'testId' => [
27
                'src' => 'test.md'
28
            ]
29
        ];
30
        $this->contentCreator = $this->getMockBuilder(ContentCreator::class)
31
            ->setMethods(['__invoke'])
32
            ->disableOriginalConstructor()
33
            ->getMock();
34
        $this->mdDocumentParser = $this->getMockBuilder(MarkdownDocumentParser::class)
35
            ->setMethods(['__invoke'])
36
            ->disableOriginalConstructor()
37
            ->getMock();
38
        $this->parser = new EntryParser($this->contentCreator, $this->mdDocumentParser, $this->config,
39
            __DIR__ . '/_files/');
40
    }
41
42
    public function testGetContentDir()
43
    {
44
        $this->assertSame(__DIR__ . '/_files', $this->parser->getContentDir());
45
    }
46
47
    public function testGetContentCreator()
48
    {
49
        $this->assertSame($this->contentCreator, $this->parser->getContentCreator());
50
    }
51
52
    public function testGetMarkdownDocumentParser()
53
    {
54
        $this->assertSame($this->mdDocumentParser, $this->parser->getMarkdownDocumentParser());
55
    }
56
57
    public function testGetConfig()
58
    {
59
        $this->assertSame($this->config, $this->parser->getConfig());
60
    }
61
62
    public function testInvoke()
63
    {
64
        $contentType = $this->createMock(ContentTypeInterface::class);
65
        $markdownDocument = new MarkdownDocument([], 'testContent');
66
        $this->mdDocumentParser->expects($this->once())
67
            ->method('__invoke')
68
            ->with($this->equalTo('testContent'))
69
            ->will($this->returnValue($markdownDocument));
70
71
        $this->contentCreator->expects($this->once())
72
            ->method('__invoke')
73
            ->with($this->equalTo($markdownDocument))
74
            ->will($this->returnValue($contentType));
75
76
        $this->assertSame($contentType, $this->parser->__invoke('testId'));
77
    }
78
}