1<?php 2 3/** 4 * Tests the move support for adapting the syntax of the include plugin 5 * 6 * @group plugin_include 7 * @group plugins 8 */ 9class plugin_include_pagemove_support_test extends DokuWikiTest { 10 public function setUp() : void 11 { 12 $this->pluginsEnabled[] = 'move'; 13 $this->pluginsEnabled[] = 'include'; 14 parent::setUp(); 15 } 16 17 public function test_relative_include() { 18 /** @var $move helper_plugin_move_op */ 19 $move = plugin_load('helper', 'move_op'); 20 if (!$move) { 21 $this->markTestSkipped('the move plugin is not installed'); 22 return; 23 } 24 saveWikiText('editx', '{{page>start#start}} %%{{page>start}}%% {{section>wiki:syntax#tables&nofooter}} {{page>:}} {{section>test:start#test}}', 'Testcase created'); 25 idx_addPage('editx'); 26 $this->assertTrue($move->movePage('editx', 'test:editx')); 27 $this->assertEquals('{{page>:start#start}} %%{{page>start}}%% {{section>wiki:syntax#tables&nofooter}} {{page>:}} {{section>test:start#test}}',rawWiki('test:editx')); 28 } 29 30 public function test_rename() { 31 /** @var $move helper_plugin_move_op */ 32 $move = plugin_load('helper', 'move_op'); 33 if (!$move) { 34 $this->markTestSkipped('the move plugin is not installed'); 35 return; 36 } 37 saveWikiText('editx', 'Page to rename', 'Testcase create'); 38 saveWikiText('links', '{{section>links#foo}} {{page>editx}} {{page>:eDitX&nofooter}} {{section>editx#test}} {{page>editx&nofooter}}', 'Testcase created'); 39 idx_addPage('editx'); 40 idx_addPage('links'); 41 42 $this->assertTrue($move->movePage('editx', 'test:edit')); 43 $this->assertEquals('{{section>links#foo}} {{page>test:edit}} {{page>test:edit&nofooter}} {{section>test:edit#test}} {{page>test:edit&nofooter}}', rawWiki('links')); 44 } 45 46 public function test_relative_include_adaption() { 47 /** @var $move helper_plugin_move_op */ 48 $move = plugin_load('helper', 'move_op'); 49 if (!$move) { 50 $this->markTestSkipped('the move plugin is not installed'); 51 return; 52 } 53 54 $text = '====== Main ====== 55 56This is a test page 57 58[[.1:page_1|link]] 59 60{{page>.1:page_1&nofooter&noeditbutton}} 61 62{{page>.1:page_2&nofooter&noeditbutton}}'; 63 64 saveWikiText('old:namespace:main', $text, 'Created'); 65 saveWikiText('old:namespace:1:page_1', 'Page 1', 'Created'); 66 saveWikiText('old:namespace:1:page_2', 'Page 2', 'Created'); 67 idx_addPage('old:namespace:main'); 68 idx_addPage('old:namespace:1:page_1'); 69 idx_addPage('old:namespace:1:page_2'); 70 71 $this->assertTrue($move->movePage('old:namespace:main', 'new:namespace:main')); 72 $this->assertTrue($move->movePage('old:namespace:1:page_1', 'new:namespace:1:page_1')); 73 $this->assertTrue($move->movePage('old:namespace:1:page_2', 'new:namespace:1:page_2')); 74 $this->assertEquals($text, rawWiki('new:namespace:main')); 75 } 76} 77