xref: /plugin/dbquery/_test/QueryTest.php (revision 8c959d24b696ff8581ebb6c224e42dbccd2d5b96)
1a488d6bbSAndreas Gohr<?php
2a488d6bbSAndreas Gohr
3a488d6bbSAndreas Gohrnamespace dokuwiki\plugin\dbquery\test;
4a488d6bbSAndreas Gohr
5a488d6bbSAndreas Gohruse DokuWikiTest;
6a488d6bbSAndreas Gohr
7a488d6bbSAndreas Gohr/**
8a488d6bbSAndreas Gohr * Query execution tests for the dbquery plugin
9a488d6bbSAndreas Gohr *
10a488d6bbSAndreas Gohr * @group plugin_dbquery
11a488d6bbSAndreas Gohr * @group plugins
12a488d6bbSAndreas Gohr */
13a488d6bbSAndreas Gohrclass QueryTest extends DokuWikiTest
14a488d6bbSAndreas Gohr{
15a488d6bbSAndreas Gohr
16a488d6bbSAndreas Gohr    /**
17a488d6bbSAndreas Gohr     * @see testUrlParsing
18a488d6bbSAndreas Gohr     */
19a488d6bbSAndreas Gohr    public function provideLinkContent()
20a488d6bbSAndreas Gohr    {
21a488d6bbSAndreas Gohr        return [
22a488d6bbSAndreas Gohr            ['foo bar', '/^foo bar$/'],
23a488d6bbSAndreas Gohr            ['[[]]', '/^\[\[\]\]$/'],
24a488d6bbSAndreas Gohr            ['Nope [[wiki]]', '/^Nope \[\[wiki\]\]$/'],
25a488d6bbSAndreas Gohr            ['[[wiki]]', '/data-wiki-id="wiki">wiki</'],
26a488d6bbSAndreas Gohr            ['[[wiki|]]', '/data-wiki-id="wiki">wiki</'],
27a488d6bbSAndreas Gohr            ['[[wiki|Test]]', '/data-wiki-id="wiki">Test</'],
28a488d6bbSAndreas Gohr            ['[[http://foobar]]', '/href="http:\/\/foobar".*>.*foobar</'],
29a488d6bbSAndreas Gohr            ['[[http://foobar|Test]]', '/href="http:\/\/foobar".*>Test</'],
30a488d6bbSAndreas Gohr        ];
31a488d6bbSAndreas Gohr    }
32a488d6bbSAndreas Gohr
33a488d6bbSAndreas Gohr    /**
34a488d6bbSAndreas Gohr     * @dataProvider provideLinkContent
35a488d6bbSAndreas Gohr     */
36a488d6bbSAndreas Gohr    public function testUrlParsing($content, $expect)
37a488d6bbSAndreas Gohr    {
38a488d6bbSAndreas Gohr        $plugin = new \syntax_plugin_dbquery_query();
39a488d6bbSAndreas Gohr        $R = new \Doku_Renderer_xhtml();
40a488d6bbSAndreas Gohr
41a488d6bbSAndreas Gohr        $this->callInaccessibleMethod($plugin, 'cellFormat', [$content, $R]);
42a488d6bbSAndreas Gohr
43*8c959d24SAndreas Gohr        $this->assertRegExp($expect, $R->doc);
44a488d6bbSAndreas Gohr    }
45a488d6bbSAndreas Gohr}
46