1<?php
2
3namespace dokuwiki\plugin\dbquery\test;
4
5use DokuWikiTest;
6
7/**
8 * Query execution tests for the dbquery plugin
9 *
10 * @group plugin_dbquery
11 * @group plugins
12 */
13class QueryTest extends DokuWikiTest
14{
15
16    /**
17     * @see testUrlParsing
18     */
19    public function provideLinkContent()
20    {
21        return [
22            ['foo bar', '/^foo bar$/'],
23            ['[[]]', '/^\[\[\]\]$/'],
24            ['Nope [[wiki]]', '/^Nope \[\[wiki\]\]$/'],
25            ['[[wiki]]', '/data-wiki-id="wiki">wiki</'],
26            ['[[wiki|]]', '/data-wiki-id="wiki">wiki</'],
27            ['[[wiki|Test]]', '/data-wiki-id="wiki">Test</'],
28            ['[[http://foobar]]', '/href="http:\/\/foobar".*>.*foobar</'],
29            ['[[http://foobar|Test]]', '/href="http:\/\/foobar".*>Test</'],
30        ];
31    }
32
33    /**
34     * @dataProvider provideLinkContent
35     */
36    public function testUrlParsing($content, $expect)
37    {
38        $plugin = new \syntax_plugin_dbquery_query();
39        $R = new \Doku_Renderer_xhtml();
40
41        $this->callInaccessibleMethod($plugin, 'cellFormat', [$content, $R, 'content']);
42
43        $this->assertRegExp($expect, $R->doc);
44    }
45
46    /**
47     * @see testWikiParsing
48     */
49    public function provideWikiContent()
50    {
51        return [
52            ['**bold**', '/<strong>bold<\/strong>/'],
53            ['//italic//', '/<em>italic<\/em>/'],
54            ['===== head =====', '/<p>\s*<strong>head<\/strong>\s*<\/p>/'],
55            ['  * list item', '/<ul>\s*<li.*><div class="li">\s*list item<\/div>\s*<\/li>\s*<\/ul>/'],
56        ];
57    }
58
59    /**
60     * @dataProvider provideWikiContent
61     */
62    public function testWikiParsing($content, $expect)
63    {
64        $plugin = new \syntax_plugin_dbquery_query();
65        $R = new \Doku_Renderer_xhtml();
66
67        $this->callInaccessibleMethod($plugin, 'cellFormat', [$content, $R, 'content_wiki']);
68
69        $this->assertRegExp($expect, $R->doc);
70    }
71}
72