renderer_plugin_prosemirror_test::test_renderer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
rs 10
1
<?php
2
3
/**
4
 * General tests for the prosemirror plugin
5
 *
6
 * @group plugin_prosemirror
7
 * @group plugins
8
 */
9
class renderer_plugin_prosemirror_test extends DokuWikiTest
10
{
11
12
    protected $pluginsEnabled = ['prosemirror', 'wrap'];
13
14
    /**
15
     * @dataProvider rendererProvider
16
     *
17
     * @param string $dokuwikiMarkup
18
     * @param string $expectedJSON
19
     * @param string $msg
20
     */
21
    public function test_renderer($dokuwikiMarkup, $expectedJSON, $msg)
22
    {
23
        global $ID;
24
        $ID = 'wiki:syntax';
25
        $instructions = p_get_instructions($dokuwikiMarkup);
26
        $doc = p_render('prosemirror', $instructions, $info);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $info seems to be never defined.
Loading history...
27
        $this->assertJsonStringEqualsJsonString($expectedJSON, $doc, $msg);
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function rendererProvider()
34
    {
35
        $data = [];
36
37
        $files = glob(__DIR__ . '/json/*.json');
38
        foreach ($files as $file) {
39
            $name = basename($file, '.json');
40
            $json = file_get_contents(__DIR__ . '/json/' . $name . '.json');
41
            $wiki = file_get_contents(__DIR__ . '/json/' . $name . '.txt');
42
            $data[] = [$wiki, $json, $name];
43
        }
44
45
        return $data;
46
    }
47
}
48