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

MetaTest::testDataWithoutMetaDataBlock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 7
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 1
rs 10
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