pagemove_support.test.php 2.9 KB

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