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