Completed
Push — master ( 974133...f3d891 )
by Marc
05:38
created

MarkdownRendererTest::testIntegrity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Kaloa\Tests;
4
5
use Kaloa\Renderer\Factory;
6
use PHPUnit_Framework_TestCase;
7
8
class MarkdownRendererTest extends PHPUnit_Framework_TestCase
9
{
10
    public function testIntegrity()
11
    {
12
        $renderer = Factory::createRenderer('markdown');
13
        $output = $renderer->render('# Hello World!');
14
15
        $this->assertEquals("<h1>Hello World!</h1>\n", $output);
16
    }
17
18
    public function basicParserProvider()
19
    {
20
        $sets = array();
21
22
        foreach (glob(__DIR__ . '/examples/markdown/*.text') as $file) {
23
            $sets[] = array(
24
                realpath($file),
25
                realpath(substr($file, 0, -5) . '.xhtml')
26
            );
27
        }
28
29
        return $sets;
30
    }
31
32
    /**
33
     * @dataProvider basicParserProvider
34
     */
35
    public function testBasicParser($fileInput, $fileExpected)
36
    {
37
        $renderer = Factory::createRenderer('markdown');
38
39
        $output = $renderer->render(file_get_contents($fileInput));
40
41
        $expected = file_get_contents($fileExpected);
42
43
        $output   = str_replace(array("\r\n", "\r"), "\n", $output);
44
        $expected = str_replace(array("\r\n", "\r"), "\n", $expected);
45
46
        $this->assertEquals($expected, $output);
47
    }
48
}
49