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 41*19d0a884SAndreas Gohr $this->callInaccessibleMethod($plugin, 'cellFormat', [$content, $R, 'content']); 42*19d0a884SAndreas Gohr 43*19d0a884SAndreas Gohr $this->assertRegExp($expect, $R->doc); 44*19d0a884SAndreas Gohr } 45*19d0a884SAndreas Gohr 46*19d0a884SAndreas Gohr /** 47*19d0a884SAndreas Gohr * @see testWikiParsing 48*19d0a884SAndreas Gohr */ 49*19d0a884SAndreas Gohr public function provideWikiContent() 50*19d0a884SAndreas Gohr { 51*19d0a884SAndreas Gohr return [ 52*19d0a884SAndreas Gohr ['**bold**', '/<strong>bold<\/strong>/'], 53*19d0a884SAndreas Gohr ['//italic//', '/<em>italic<\/em>/'], 54*19d0a884SAndreas Gohr ['===== head =====', '/<p>\s*<strong>head<\/strong>\s*<\/p>/'], 55*19d0a884SAndreas Gohr [' * list item', '/<ul>\s*<li.*><div class="li">\s*list item<\/div>\s*<\/li>\s*<\/ul>/'], 56*19d0a884SAndreas Gohr ]; 57*19d0a884SAndreas Gohr } 58*19d0a884SAndreas Gohr 59*19d0a884SAndreas Gohr /** 60*19d0a884SAndreas Gohr * @dataProvider provideWikiContent 61*19d0a884SAndreas Gohr */ 62*19d0a884SAndreas Gohr public function testWikiParsing($content, $expect) 63*19d0a884SAndreas Gohr { 64*19d0a884SAndreas Gohr $plugin = new \syntax_plugin_dbquery_query(); 65*19d0a884SAndreas Gohr $R = new \Doku_Renderer_xhtml(); 66*19d0a884SAndreas Gohr 67*19d0a884SAndreas Gohr $this->callInaccessibleMethod($plugin, 'cellFormat', [$content, $R, 'content_wiki']); 68a488d6bbSAndreas Gohr 698c959d24SAndreas Gohr $this->assertRegExp($expect, $R->doc); 70a488d6bbSAndreas Gohr } 71a488d6bbSAndreas Gohr} 72