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]);
42
43        $this->assertRegExp($expect, $R->doc);
44    }
45}
46