raster pushed a commit to branch master. http://git.enlightenment.org/website/www.git/commit/?id=0f50b1cb169d6d77a18bdc846082359297b69888
commit 0f50b1cb169d6d77a18bdc846082359297b69888 Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Fri Apr 17 09:57:07 2015 +0900 Revert "MEDIUM: Remove test files" This reverts commit 2bf5829e214c61646ad1043c5370f6a2c7f5c995. --- .../lib/plugins/const/_test/calculation.test.php | 25 ++++ .../lib/plugins/const/_test/constants.test.php | 102 +++++++++++++++ .../lib/plugins/const/_test/fix_section.test.php | 74 +++++++++++ .../include/_test/locallink_conversion.test.php | 38 ++++++ .../_test/media_linktitle_conversion.test.php | 50 ++++++++ .../include/_test/namespace_includes.test.php | 140 +++++++++++++++++++++ .../plugins/include/_test/nested_include.test.php | 68 ++++++++++ .../include/_test/pagemove_support.test.php | 45 +++++++ .../lib/plugins/include/_test/safeindex.test.php | 36 ++++++ 9 files changed, 578 insertions(+) diff --git a/public_html/lib/plugins/const/_test/calculation.test.php b/public_html/lib/plugins/const/_test/calculation.test.php new file mode 100644 index 0000000..bf7f5ea --- /dev/null +++ b/public_html/lib/plugins/const/_test/calculation.test.php @@ -0,0 +1,25 @@ +<?php +/** + * @group plugin_const + * @group plugins + */ +class plugin_const_calculation_test extends DokuWikiTest { + + public function setup() { + $this->pluginsEnabled[] = 'const'; + parent::setup(); + } + + public function test_math() { + saveWikiText('test:plugin_const:math', + '<const>'.DOKU_LF + .'value1=4'.DOKU_LF + .'formular=value1 * 10 +2'.DOKU_LF + .'result:formular'.DOKU_LF + .'</const>'.DOKU_LF + .'%%result%%'.DOKU_LF, + 'setup for test'); + $HTML = p_wiki_xhtml('test:plugin_const:math'); + $this->assertTrue(strpos($HTML, '42') !== false, 'Calculation is 42'); + } +} diff --git a/public_html/lib/plugins/const/_test/constants.test.php b/public_html/lib/plugins/const/_test/constants.test.php new file mode 100644 index 0000000..58ea47f --- /dev/null +++ b/public_html/lib/plugins/const/_test/constants.test.php @@ -0,0 +1,102 @@ +<?php +/** + * @group plugin_const + * @group plugins + */ +class plugin_const_constants_test extends DokuWikiTest { + + public function setup() { + $this->pluginsEnabled[] = 'const'; + parent::setup(); + } + + public function test_page_user_constants() { + saveWikiText('test:plugin_const:pageconstants', + '<const>'.DOKU_LF + .'ID=%ID%'.DOKU_LF + .'namespace=%NAMESPACE%'.DOKU_LF + .'User=%USER%'.DOKU_LF + .'</const>'.DOKU_LF + .'ID:%%ID%%'.DOKU_LF + .'NAMESPACE:%%namespace%%'.DOKU_LF + .'User:%%User%%'.DOKU_LF, + 'setup for test'); + + $request = new TestRequest(); + $response = $request->get(array('id' => 'test:plugin_const:pageconstants'), '/doku.php'); + $HTML = $response->queryHTML('.page p'); + + $this->assertTrue(strpos($HTML, 'ID:pageconstants') !== false, 'Page ID is pageconstants'); + $this->assertTrue(strpos($HTML, 'NAMESPACE:test:plugin_const') !== false, 'Namespace is test:plugin_const'); + $this->assertTrue(strpos($HTML, 'User:') !== false, 'anonymous'); + } + + public function test_date_constants() { + saveWikiText('test:plugin_const:dateconstants', + '<const>'.DOKU_LF + .'YEAR=%YEAR%'.DOKU_LF + .'MONTH=%MONTH%'.DOKU_LF + .'MONTHNAME=%MONTHNAME%'.DOKU_LF + .'WEEK=%WEEK%'.DOKU_LF + .'DAY=%DAY%'.DOKU_LF + .'DAYNAME=%DAYNAME%'.DOKU_LF + .'</const>'.DOKU_LF + + .'YEAR:%%YEAR%%'.DOKU_LF + .'MONTH:%%MONTH%%'.DOKU_LF + .'MONTHNAME:%%MONTHNAME%%'.DOKU_LF + .'WEEK:%%WEEK%%'.DOKU_LF + .'DAY:%%DAY%%'.DOKU_LF + .'DAYNAME:%%DAYNAME%%'.DOKU_LF, + + 'setup for test'); + + $request = new TestRequest(); + $response = $request->get(array('id' => 'test:plugin_const:dateconstants'), '/doku.php'); + $HTML = $response->queryHTML('.page p'); + + $this->assertTrue(strpos($HTML, 'YEAR:'.date('Y')) !== false); + $this->assertTrue(strpos($HTML, 'MONTH:'.date('m')) !== false); + $this->assertTrue(strpos($HTML, 'MONTHNAME:'.date('F')) !== false); + $this->assertTrue(strpos($HTML, 'WEEK:'.date('W')) !== false); + $this->assertTrue(strpos($HTML, 'DAY:'.date('d')) !== false); + $this->assertTrue(strpos($HTML, 'DAYNAME:'.date('l')) !== false); + } + + public function test_other_constants() { + + saveWikiText('test:plugin_const:otherconstants', + '<const>'.DOKU_LF + .'RANDOM=%RANDOM%'.DOKU_LF + .'AUTOINDEX=%AUTOINDEX%'.DOKU_LF + .'</const>'.DOKU_LF + .'RANDOM:%%RANDOM%%'.DOKU_LF + .'AUTOINDEX1:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX2:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX_:%%AUTOINDEX%%'.DOKU_LF + .'AUTOINDEX15:%%AUTOINDEX%%'.DOKU_LF, + + 'setup for test'); + + $request = new TestRequest(); + $response = $request->get(array('id' => 'test:plugin_const:otherconstants'), '/doku.php'); + $HTML = $response->queryHTML('.page p'); + + $this->assertTrue(@preg_match('/RANDOM:\d+/',$HTML) === 1); + $this->assertTrue(strpos($HTML, 'AUTOINDEX1:1') !== false); + $this->assertTrue(strpos($HTML, 'AUTOINDEX2:2') !== false); + $this->assertTrue(strpos($HTML, 'AUTOINDEX15:15') !== false); + + } +} diff --git a/public_html/lib/plugins/const/_test/fix_section.test.php b/public_html/lib/plugins/const/_test/fix_section.test.php new file mode 100644 index 0000000..3c484a6b --- /dev/null +++ b/public_html/lib/plugins/const/_test/fix_section.test.php @@ -0,0 +1,74 @@ +<?php +/** + * @group plugin_const + * @group plugins + */ +class plugin_const_include_support_test extends DokuWikiTest { + + public function setup() { + $this->pluginsEnabled[] = 'const'; + $this->pluginsEnabled[] = 'include'; + $this->_createPages(); + parent::setup(); + } + + public function test_basic_sectionfix() { + $request = new TestRequest(); + $response = $request->get(array('id' => 'test:plugin_const:start'), '/doku.php'); + + $first_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(0)->attr('value'); + $second_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(1)->attr('value'); + $third_sec = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(2)->attr('value'); + + $this->assertEquals('57-87', $first_sec); + $this->assertEquals('88-118', $second_sec); + $this->assertEquals('119-', $third_sec); + } + + public function test_include_sectionfix() { + $request = new TestRequest(); + $response = $request->get(array('id' => 'test:plugin_const:include'), '/doku.php'); + + $section = array(); + + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(0)->attr('value'); + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(1)->attr('value'); + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(2)->attr('value'); + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(3)->attr('value'); + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(4)->attr('value'); + $section[] = $response->queryHTML('form.btn_secedit input[name="range"]')->eq(5)->attr('value'); + + $this->assertEquals('71-101', $section[0]); + $this->assertEquals('57-87', $section[1]); + $this->assertEquals('88-118', $section[2]); + $this->assertEquals('119-', $section[3]); + $this->assertEquals('102-141', $section[4]); + $this->assertEquals('142-', $section[5]); + } + + private function _createPages() { + saveWikiText('test:plugin_const:include', + '<const>'.DOKU_LF + .'var1=test:plugin_const:start'.DOKU_LF + .'var2=123456789123456789'.DOKU_LF + .'</const>'.DOKU_LF + .'====== Header1 ======'.DOKU_LF + .'%%var2%%'.DOKU_LF + .'====== Header2 ======'.DOKU_LF + .'{{page>%%var1%%}}'.DOKU_LF + .'====== Header3 ======'.DOKU_LF, + 'setup for test'); + saveWikiText('test:plugin_const:start', + '<const>'.DOKU_LF + .'var1=123456789'.DOKU_LF + .'var2=123456789123456789'.DOKU_LF + .'</const>'.DOKU_LF + .'====== Header1 ======'.DOKU_LF + .'%%var2%%'.DOKU_LF + .'====== Header2 ======'.DOKU_LF + .'%%var2%%'.DOKU_LF + .'====== Header3 ======'.DOKU_LF, + 'setup for test'); + } + +} diff --git a/public_html/lib/plugins/include/_test/locallink_conversion.test.php b/public_html/lib/plugins/include/_test/locallink_conversion.test.php new file mode 100644 index 0000000..b344237 --- /dev/null +++ b/public_html/lib/plugins/include/_test/locallink_conversion.test.php @@ -0,0 +1,38 @@ +<?php + +if (!defined('DOKU_INC')) die(); + +/** + * Test the conversion of local links to internal links if the page hasn't been fully included + */ +class plugin_include_locallink_conversion_test extends DokuWikiTest { + /** @var helper_plugin_include $helper */ + private $helper; + + public function setUp() { + $this->pluginsEnabled[] = 'include'; + parent::setUp(); + + $this->helper = plugin_load('helper', 'include'); + + saveWikiText('included', 'Example content with link [[#jump]]', 'Test setup'); + idx_addPage('test:included'); + + saveWikiText('test:includefull', '{{page>..:included}}', 'Test setup'); + idx_addPage('test:includefull'); + + saveWikiText('test:includefirst', '{{page>..:included&firstseconly}}', 'Test setup'); + idx_addPage('test:includefirst'); + } + + public function testLocalConverted() { + $html = p_wiki_xhtml('test:includefirst'); + $this->assertContains('href="'.wl('included').'#jump"', $html); + $this->assertNotContains('href="#jump"', $html); + } + + public function testLocalExistsIfIncluded() { + $html = p_wiki_xhtml('test:includefull'); + $this->assertContains('href="#jump"', $html); + } +} diff --git a/public_html/lib/plugins/include/_test/media_linktitle_conversion.test.php b/public_html/lib/plugins/include/_test/media_linktitle_conversion.test.php new file mode 100644 index 0000000..050f9d7 --- /dev/null +++ b/public_html/lib/plugins/include/_test/media_linktitle_conversion.test.php @@ -0,0 +1,50 @@ +<?php + +if (!defined('DOKU_INC')) die(); + +/** + * Test the conversion of media references in link titles + */ +class plugin_include_media_linktitle_conversion_test extends DokuWikiTest { + /** @var helper_plugin_include $helper */ + private $helper; + + public function setUp() { + $this->pluginsEnabled[] = 'include'; + parent::setUp(); + + $this->helper = plugin_load('helper', 'include'); + + saveWikiText('wiki:included', <<<EOF + * [[test|{{dokuwiki.png}}]] + * [[#test|{{dokuwiki.png?w=200}}]] + * [[doku>test|{{dokuwiki.png?w=300}}]] + * [[test|{{https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png}}]] +EOF + , 'Test setup'); + idx_addPage('wiki:included'); + + saveWikiText('test:include', '{{page>..:wiki:included}}', 'Test setup'); + idx_addPage('test:include'); + } + + public function testInternalLinkTitleConversion() { + $html = p_wiki_xhtml('test:include'); + $this->assertContains('src="'.ml('wiki:dokuwiki.png').'"', $html); + } + + public function testLocalLinkTitleConversion() { + $html = p_wiki_xhtml('test:include'); + $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '200')).'"', $html); + } + + public function testInterWikiLinkTitleConversion() { + $html = p_wiki_xhtml('test:include'); + $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html); + } + + public function testExternalMediaNotConverted() { + $html = p_wiki_xhtml('test:include'); + $this->assertContains('src="'.ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png').'"', $html); + } +} \ No newline at end of file diff --git a/public_html/lib/plugins/include/_test/namespace_includes.test.php b/public_html/lib/plugins/include/_test/namespace_includes.test.php new file mode 100644 index 0000000..4283438 --- /dev/null +++ b/public_html/lib/plugins/include/_test/namespace_includes.test.php @@ -0,0 +1,140 @@ +<?php + +if (!defined('DOKU_INC')) die(); + +/** + * Test namespace includes + */ +class plugin_include_namespaces_includes_test extends DokuWikiTest { + /** + * @var helper_plugin_include $helper + */ + private $helper; + + /** + * Setup - enable and load the include plugin and create the test pages + */ + public function setup() { + $this->pluginsEnabled[] = 'include'; + parent::setup(); // this enables the include plugin + $this->helper = plugin_load('helper', 'include'); + + global $conf; + $conf['hidepages'] = 'inclhidden:hidden'; + + // for testing hidden pages + saveWikiText('inclhidden:hidden', 'Hidden page', 'Created hidden page'); + saveWikiText('inclhidden:visible', 'Visible page', 'Created visible page'); + + // pages on different levels + saveWikiText('incltest:level1', 'Page on level 1', 'Created page on level 1'); + saveWikiText('incltest:ns:level2', 'Page on level 2', 'Created page on level 2'); + saveWikiText('incltest:ns:ns:level3', 'Page on level 3', 'Created page on level 3'); + + // for page ordering + saveWikiText('inclorder:page1', 'Page 1', 'Created page 1'); + saveWikiText('inclorder:page2', 'Page 2', 'Created page 2'); + saveWikiText('inclorder:page3', '{{include_n>10}} Page 3/10', 'created page 3/1'); + saveWikiText('inclorder:page4', '{{include_n>2}} Page 4/2', 'created page 4/0'); + } + + /** + * Test hiding of hidden pages in namespace includes + */ + public function test_hidden() { + $flags = $this->helper->get_flags(array()); + $pages = $this->helper->_get_included_pages('namespace', 'inclhidden:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'inclhidden:visible', 'exists' => true, 'parent_id' => ''), + ), $pages); + } + + /** + * Test include depth limit + */ + public function test_depth() { + $flags = $this->helper->get_flags(array()); + $pages = $this->helper->_get_included_pages('namespace', 'incltest:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'incltest:level1', 'exists' => true, 'parent_id' => ''), + ), $pages); + $flags = $this->helper->get_flags(array('depth=2')); + $pages = $this->helper->_get_included_pages('namespace', 'incltest:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'incltest:level1', 'exists' => true, 'parent_id' => ''), + array('id' => 'incltest:ns:level2', 'exists' => true, 'parent_id' => ''), + ), $pages); + $flags = $this->helper->get_flags(array('depth=2')); + $pages = $this->helper->_get_included_pages('namespace', 'incltest:ns', '', '', $flags); + $this->assertEquals(array( + array('id' => 'incltest:ns:level2', 'exists' => true, 'parent_id' => ''), + array('id' => 'incltest:ns:ns:level3', 'exists' => true, 'parent_id' => ''), + ), $pages); + $flags = $this->helper->get_flags(array('depth=0')); + $pages = $this->helper->_get_included_pages('namespace', 'incltest:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'incltest:level1', 'exists' => true, 'parent_id' => ''), + array('id' => 'incltest:ns:level2', 'exists' => true, 'parent_id' => ''), + array('id' => 'incltest:ns:ns:level3', 'exists' => true, 'parent_id' => ''), + ), $pages); + + // test include of the root namespace + $flags = $this->helper->get_flags(array()); + $pages = $this->helper->_get_included_pages('namespace', ':', '', '', $flags); + $this->assertEquals(array(), $pages); + $flags = $this->helper->get_flags(array('depth=2')); + $pages = $this->helper->_get_included_pages('namespace', ':', '', '', $flags); + $this->assertEquals(array( + array('id' => 'inclhidden:visible', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page1', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page2', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page3', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page4', 'exists' => true, 'parent_id' => ''), + array('id' => 'incltest:level1', 'exists' => true, 'parent_id' => ''), + array('id' => 'wiki:dokuwiki', 'exists' => true, 'parent_id' => ''), + array('id' => 'wiki:syntax', 'exists' => true, 'parent_id' => ''), + ), $pages); + } + + /** + * Test ordering of namespace includes + */ + public function test_order() { + + $flags = $this->helper->get_flags(array()); + $pages = $this->helper->_get_included_pages('namespace', 'inclorder:', '', '', $flags); + + $this->assertEquals(array( + array('id' => 'inclorder:page1', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page2', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page3', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page4', 'exists' => true, 'parent_id' => ''), + ), $pages); + + $flags = $this->helper->get_flags(array('rsort')); + $pages = $this->helper->_get_included_pages('namespace', 'inclorder:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'inclorder:page4', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page3', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page2', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page1', 'exists' => true, 'parent_id' => ''), + ), $pages); + $flags = $this->helper->get_flags(array('order=custom')); + $pages = $this->helper->_get_included_pages('namespace', 'inclorder:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'inclorder:page4', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page3', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page1', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page2', 'exists' => true, 'parent_id' => ''), + ), $pages); + + $flags = $this->helper->get_flags(array('order=custom', 'rsort')); + $pages = $this->helper->_get_included_pages('namespace', 'inclorder:', '', '', $flags); + $this->assertEquals(array( + array('id' => 'inclorder:page2', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page1', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page3', 'exists' => true, 'parent_id' => ''), + array('id' => 'inclorder:page4', 'exists' => true, 'parent_id' => ''), + ), $pages); + } +} diff --git a/public_html/lib/plugins/include/_test/nested_include.test.php b/public_html/lib/plugins/include/_test/nested_include.test.php new file mode 100644 index 0000000..4dfb527 --- /dev/null +++ b/public_html/lib/plugins/include/_test/nested_include.test.php @@ -0,0 +1,68 @@ +<?php + +class plugin_include_nested_test extends DokuWikiTest { + private $ids = array( + 'test:plugin_include:nested:start', + 'test:plugin_include:nested:second', + 'test:plugin_include:nested:third' + ); + + public function setup() { + $this->pluginsEnabled[] = 'include'; + parent::setup(); + } + + public function test_outer_to_inner() { + $this->_createPages(); + $mainHTML = p_wiki_xhtml('test:plugin_include:nested:start'); + $secondHTML = p_wiki_xhtml('test:plugin_include:nested:second'); + $thirdHTML = p_wiki_xhtml('test:plugin_include:nested:third'); + $this->_validateContent($mainHTML, $secondHTML, $thirdHTML); + } + + public function test_inner_to_outer() { + $this->_createPages(); + $thirdHTML = p_wiki_xhtml('test:plugin_include:nested:third'); + $secondHTML = p_wiki_xhtml('test:plugin_include:nested:second'); + $mainHTML = p_wiki_xhtml('test:plugin_include:nested:start'); + $this->_validateContent($mainHTML, $secondHTML, $thirdHTML); + } + + private function _validateContent($mainHTML, $secondHTML, $thirdHTML) { + $this->assertTrue(strpos($mainHTML, 'Main Content') !== false, 'Main content contains "Main Content"'); + $this->assertTrue($this->_matchHeader('1', 'Main Test Page', $mainHTML), 'Main page header is h1'); + $this->assertTrue(strpos($mainHTML, 'Second Content') !== false, 'Main content contains "Second Content"'); + $this->assertTrue($this->_matchHeader('2', 'Second Test Page', $mainHTML), 'Second page header on main page is h2'); + $this->assertTrue(strpos($mainHTML, 'Third Content') !== false, 'Main content contains "Third Content"'); + $this->assertTrue($this->_matchHeader('3', 'Third Test Page', $mainHTML), 'Third page header on main page is h3'); + $this->assertTrue(strpos($secondHTML, 'Second Content') !== false, 'Second content contains "Second Content"'); + $this->assertTrue($this->_matchHeader('1', 'Second Test Page', $secondHTML), 'Second page header on second page is h1'); + $this->assertTrue(strpos($secondHTML, 'Third Content') !== false, 'Second content contains "Third Content"'); + $this->assertTrue($this->_matchHeader('2', 'Third Test Page', $secondHTML), 'Third page header on second page is h2'); + $this->assertTrue(strpos($thirdHTML, 'Third Content') !== false, 'Third content contains "Third Content"'); + $this->assertTrue($this->_matchHeader('1', 'Third Test Page', $thirdHTML), 'Third page header on third page is h1'); + } + + private function _matchHeader($level, $text, $html) { + return preg_match('/<h'.$level.'[^>]*>(<a[^>]*>)?'.$text.'/', $html) > 0; + } + + private function _createPages() { + saveWikiText('test:plugin_include:nested:start', + '====== Main Test Page ======'.DOKU_LF.DOKU_LF + .'Main Content'.rand().DOKU_LF.DOKU_LF + .'{{page>second}}'.DOKU_LF, + 'setup for test'); + saveWikiText('test:plugin_include:nested:second', + '====== Second Test Page ======'.DOKU_LF.DOKU_LF + .'Second Content'.rand().DOKU_LF.DOKU_LF + .'{{page>third}}'.DOKU_LF, + 'setup for test'); + saveWikiText('test:plugin_include:nested:third', + '====== Third Test Page ======'.DOKU_LF.DOKU_LF + .'Third Content'.rand().DOKU_LF.DOKU_LF + .'{{page>third}}'.DOKU_LF, + 'setup for test'); + } +} + diff --git a/public_html/lib/plugins/include/_test/pagemove_support.test.php b/public_html/lib/plugins/include/_test/pagemove_support.test.php new file mode 100644 index 0000000..2158269 --- /dev/null +++ b/public_html/lib/plugins/include/_test/pagemove_support.test.php @@ -0,0 +1,45 @@ +<?php + +/** + * Tests the editx support for adapting the syntax of the include plugin + */ +class plugin_include_pagemove_support_test extends DokuWikiTest { + public function setup() { + $this->pluginsEnabled[] = 'move'; + $this->pluginsEnabled[] = 'include'; + parent::setup(); + } + + public function test_relative_include() { + global $ID; + /** @var $move helper_plugin_move */ + $move = plugin_load('helper', 'move'); + if (!$move) return; // disable the test when move is not installed + saveWikiText('editx', '{{page>start#start}} %%{{page>start}}%% {{section>wiki:syntax#tables&nofooter}} {{page>:}} {{section>test:start#test}}', 'Testcase created'); + idx_addPage('editx'); + $ID = 'editx'; + $opts['ns'] = ''; + $opts['newname'] = 'editx'; + $opts['newns'] = 'test'; + $move->move_page($opts); + $this->assertEquals('{{page>:start#start}} %%{{page>start}}%% {{section>wiki:syntax#tables&nofooter}} {{page>:}} {{section>test:start#test}}',rawWiki('test:editx')); + } + + public function test_rename() { + global $ID; + /** @var $move helper_plugin_move */ + $move = plugin_load('helper', 'move'); + if (!$move) return; // disable the test when move is not installed + saveWikiText('editx', 'Page to rename', 'Testcase create'); + saveWikiText('links', '{{section>links#foo}} {{page>editx}} {{page>:eDitX&nofooter}} {{section>editx#test}} {{page>editx&nofooter}}', 'Testcase created'); + idx_addPage('editx'); + idx_addPage('links'); + + $ID = 'editx'; + $opts['ns'] = ''; + $opts['newname'] = 'edit'; + $opts['newns'] = 'test'; + $move->move_page($opts); + $this->assertEquals('{{section>links#foo}} {{page>test:edit}} {{page>test:edit&nofooter}} {{section>test:edit#test}} {{page>test:edit&nofooter}}', rawWiki('links')); + } +} \ No newline at end of file diff --git a/public_html/lib/plugins/include/_test/safeindex.test.php b/public_html/lib/plugins/include/_test/safeindex.test.php new file mode 100644 index 0000000..6b94db0 --- /dev/null +++ b/public_html/lib/plugins/include/_test/safeindex.test.php @@ -0,0 +1,36 @@ +<?php + +class plugin_include_safeindex_test extends DokuWikiTest { + public function setup() { + $this->pluginsEnabled[] = 'include'; + parent::setup(); + } + + public function test_safeindex() { + global $conf; + global $AUTH_ACL; + $conf['superuser'] = 'john'; + $conf['useacl'] = 1; + + $AUTH_ACL = array( + '* @ALL 0', + '* @user 8', + 'public @ALL 1', + ); + + $_SERVER['REMOTE_USER'] = 'john'; + + saveWikiText('parent', "{{page>child}}\n\n[[public_link]]\n\n{{page>public}}", 'Test parent created'); + saveWikiText('child', "[[foo:private]]", 'Test child created'); + saveWikiText('public', "[[foo:public]]", 'Public page created'); + + idx_addPage('parent'); + idx_addPage('child'); + idx_addPage('public'); + + $this->assertEquals(array('parent', 'public'), ft_backlinks('foo:public')); + $this->assertEquals(array('child'), ft_backlinks('foo:private')); + $this->assertEquals(array('parent'), ft_backlinks('public_link')); + } +} + --