Passed
Pull Request — develop (#352)
by Schlaefer
02:09
created

MetaTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
eloc 23
dl 0
loc 36
ccs 16
cts 16
cp 1
rs 10
c 3
b 2
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testYamlWithYamlFrontMatter() 0 20 1
A testDataWithoutMetaDataBlock() 0 12 1
1
<?php
2
3
namespace Phile\Plugin\Phile\ParserMeta\Tests;
4
5
use Phile\Plugin\Phile\ParserMeta\Parser\Meta;
6
use Phile\Test\TestCase;
7
8
class MetaTest extends TestCase
9
{
10 1
    public function testYamlWithYamlFrontMatter()
11
    {
12 1
        $this->createPhileCore()->bootstrap();
13
14 1
        $raw = <<<EOF
15
---
16
Title: foo 
17
Tags: [bar, baz]
18
---
19
20
Page Content
21
EOF;
22
23 1
        $parser = new Meta([
24 1
            'fences' => ['yaml' => ['open' => '---', 'close' => '---']],
25
            'format' => 'YAML'
26
        ]);
27 1
        $meta = $parser->extractMeta($raw);
28 1
        $this->assertSame('foo', $meta['title']);
29 1
        $this->assertSame(['bar', 'baz'], $meta['tags']);
30
    }
31
32 1
    public function testDataWithoutMetaDataBlock()
33
    {
34 1
        $raw = "# Hello World\n## Hello you too";
35 1
        $parser = new Meta([
36 1
            'fences' => ['yaml' => ['open' => '---', 'close' => '---']],
37
        ]);
38
39 1
        $content = $parser->extractContent($raw);
40 1
        $this->assertSame($raw, $content);
41
42 1
        $meta = $parser->extractMeta($raw);
43 1
        $this->assertSame([], $meta);
44
    }
45
}
46