Completed
Push — master ( 4534a2...4c3ec3 )
by Johannes
03:54
created

MarkdownDocumentParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testGetFrontYamlParser() 0 4 1
A testParse() 0 16 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\Markdown;
11
12
use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser;
13
use Mni\FrontYAML\Parser;
14
use Mni\FrontYAML\Document;
15
use PHPUnit\Framework\TestCase;
16
17
class MarkdownDocumentParserTest extends TestCase
18
{
19
    private $parser, $frontYamlParser;
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...
20
21
    protected function setUp()
22
    {
23
        $this->frontYamlParser = $this->getMockBuilder(Parser::class)
24
            ->setMethods(['parse'])
25
            ->disableOriginalConstructor()
26
            ->getMock();
27
        $this->parser = new MarkdownDocumentParser($this->frontYamlParser);
28
    }
29
30
    public function testGetFrontYamlParser()
31
    {
32
        $this->assertSame($this->frontYamlParser, $this->parser->getFrontYamlParser());
33
    }
34
35
    public function testParse()
36
    {
37
        $params = [
38
            'id' => 'testId'
39
        ];
40
41
        $frontYamlDocument = new Document($params, 'testContent');
42
        $this->frontYamlParser->expects($this->once())
43
            ->method('parse')
44
            ->with($this->equalTo('testDocumentContent'))
45
            ->will($this->returnValue($frontYamlDocument));
46
47
        $markdownDocument = ($this->parser)('testDocumentContent');
48
        $this->assertSame($params, $markdownDocument->getParams());
49
        $this->assertSame('testContent', $markdownDocument->getContent());
50
    }
51
52
}