1<?php 2 3// must be run within Dokuwiki 4if (!defined('DOKU_INC')) die(); 5 6/** 7 * Test cases for the move plugin 8 * 9 * @group plugin_move 10 * @group plugins 11 */ 12class plugin_move_pagemove_test extends DokuWikiTest { 13 14 var $movedToId = ''; 15 var $movedId = 'parent_ns:current_ns:test_page'; 16 var $parentBacklinkingId = 'parent_ns:some_page'; 17 var $currentNsBacklinkingId = 'parent_ns:current_ns:some_page'; 18 var $otherBacklinkingId = 'level0:level1:other_backlinking_page'; 19 var $subNsPage = 'parent_ns:current_ns:sub_ns:some_page'; 20 21 // @todo Move page to an ID which already exists 22 // @todo Check backlinks of a sub-namespace page (moving same, up, down, different) 23 24 function setUp(): void { 25 parent::setUpBeforeClass(); 26 $this->pluginsEnabled[] = 'move'; 27 global $ID; 28 global $INFO; 29 global $conf; 30 31 $ID = $this->movedId; 32 33 $text = <<<EOT 34[[start|start]] 35[[parallel_page|parallel_page]] 36[[.:|.:]] 37[[..current_ns:|..current_ns:]] 38[[..:current_ns:|..:current_ns:]] 39[[..parallel_ns:|..parallel_ns:]] 40[[..:parallel_ns:|..:parallel_ns:]] 41[[..:..:|..:..:]] 42[[..:..:parent_ns:|..:..:parent_ns:]] 43[[parent_ns:new_page|parent_ns:new_page]] 44[[parent_ns/new_page|parent_ns/new_page]] 45[[/start|/start]] 46EOT; 47 $summary = 'Test'; 48 saveWikiText($this->movedId, $text, $summary); 49 $INFO = pageinfo(); 50 51 $references = array_keys(p_get_metadata($this->movedId, 'relation references', METADATA_RENDER_UNLIMITED)); 52 idx_get_indexer()->addMetaKeys($this->movedId, 'relation_references', $references); 53 54 $text = <<<EOT 55[[$this->movedId|$this->movedId]] 56[[:$this->movedId|:$this->movedId]] 57[[.current_ns:test_page|.current_ns:test_page]] 58[[.:current_ns:test_page|.:current_ns:test_page]] 59[[..parent_ns:current_ns:test_page|..parent_ns:current_ns:test_page]] 60[[test_page|test_page]] 61[[new_page|new_page]] 62[[ftp://somewhere.com|ftp://somewhere.com]] 63[[http://somewhere.com|http://somewhere.com]] 64 65[[start|start]] 66[[parallel_page|parallel_page]] 67[[.:|.:]] 68[[..current_ns:|..current_ns:]] 69[[..:current_ns:|..:current_ns:]] 70[[..parallel_ns:|..parallel_ns:]] 71[[..:parallel_ns:|..:parallel_ns:]] 72[[..:..:|..:..:]] 73[[..:..:parent_ns:|..:..:parent_ns:]] 74[[parent_ns:new_page|parent_ns:new_page]] 75[[parent_ns/new_page|parent_ns/new_page]] 76[[/start|/start]] 77EOT; 78 saveWikiText($this->parentBacklinkingId, $text, $summary); 79 $references = array_keys(p_get_metadata($this->parentBacklinkingId, 'relation references', METADATA_RENDER_UNLIMITED)); 80 idx_get_indexer()->addMetaKeys($this->parentBacklinkingId, 'relation_references', $references); 81 82 $text = <<<EOT 83[[$this->movedId|$this->movedId]] 84[[:$this->movedId|:$this->movedId]] 85[[..current_ns:test_page|..current_ns:test_page]] 86[[..:current_ns:test_page|..:current_ns:test_page]] 87[[test_page|test_page]] 88[[.test_page|.test_page]] 89[[.:test_page|.:test_page]] 90[[..test_page|..test_page]] 91[[..:test_page|..:test_page]] 92[[.:..:test_page|.:..:test_page]] 93[[new_page|new_page]] 94[[ftp://somewhere.com|ftp://somewhere.com]] 95[[http://somewhere.com|http://somewhere.com]] 96 97[[start|start]] 98[[parallel_page|parallel_page]] 99[[.:|.:]] 100[[..current_ns:|..current_ns:]] 101[[..:current_ns:|..:current_ns:]] 102[[..parallel_ns:|..parallel_ns:]] 103[[..:parallel_ns:|..:parallel_ns:]] 104[[..:..:|..:..:]] 105[[..:..:parent_ns:|..:..:parent_ns:]] 106[[parent_ns:new_page|parent_ns:new_page]] 107[[parent_ns/new_page|parent_ns/new_page]] 108[[/start|/start]] 109EOT; 110 saveWikiText($this->currentNsBacklinkingId, $text, $summary); 111 $references = array_keys(p_get_metadata($this->currentNsBacklinkingId, 'relation references', METADATA_RENDER_UNLIMITED)); 112 idx_get_indexer()->addMetaKeys($this->currentNsBacklinkingId, 'relation_references', $references); 113 114 $text = <<<EOT 115[[$this->movedId|$this->movedId]] 116[[:$this->movedId|:$this->movedId]] 117[[.current_ns:test_page|.current_ns:test_page]] 118[[.:current_ns:test_page|.:current_ns:test_page]] 119[[test_page|test_page]] 120[[new_page|new_page]] 121[[ftp://somewhere.com|ftp://somewhere.com]] 122[[http://somewhere.com|http://somewhere.com]] 123 124[[start|start]] 125[[parallel_page|parallel_page]] 126[[.:|.:]] 127[[..current_ns:|..current_ns:]] 128[[..:current_ns:|..:current_ns:]] 129[[..parallel_ns:|..parallel_ns:]] 130[[..:parallel_ns:|..:parallel_ns:]] 131[[..:..:|..:..:]] 132[[..:..:parent_ns:|..:..:parent_ns:]] 133[[parent_ns:new_page|parent_ns:new_page]] 134[[parent_ns/new_page|parent_ns/new_page]] 135[[/start|/start]] 136EOT; 137 saveWikiText($this->otherBacklinkingId, $text, $summary); 138 $references = array_keys(p_get_metadata($this->otherBacklinkingId, 'relation references', METADATA_RENDER_UNLIMITED)); 139 idx_get_indexer()->addMetaKeys($this->otherBacklinkingId, 'relation_references', $references); 140 141 $text = <<<EOT 142[[$this->movedId|$this->movedId]] 143[[:$this->movedId|:$this->movedId]] 144[[..:..current_ns:test_page|..:..current_ns:test_page]] 145[[..:..:current_ns:test_page|..:..:current_ns:test_page]] 146[[test_page|test_page]] 147[[..:test_page|..:test_page]] 148[[..:test_page|..:test_page]] 149[[.:..:test_page|.:..:test_page]] 150[[new_page|new_page]] 151[[..:new_page|..:new_page]] 152[[ftp://somewhere.com|ftp://somewhere.com]] 153[[http://somewhere.com|http://somewhere.com]] 154 155[[start|start]] 156[[parallel_page|parallel_page]] 157[[.:|.:]] 158[[..current_ns:|..current_ns:]] 159[[..:current_ns:|..:current_ns:]] 160[[..parallel_ns:|..parallel_ns:]] 161[[..:parallel_ns:|..:parallel_ns:]] 162[[..:..:|..:..:]] 163[[..:..:parent_ns:|..:..:parent_ns:]] 164[[parent_ns:new_page|parent_ns:new_page]] 165[[parent_ns/new_page|parent_ns/new_page]] 166[[/start|/start]] 167EOT; 168 saveWikiText($this->subNsPage, $text, $summary); 169 $references = array_keys(p_get_metadata($this->subNsPage, 'relation references', METADATA_RENDER_UNLIMITED)); 170 idx_get_indexer()->addMetaKeys($this->subNsPage, 'relation_references', $references); 171 172 parent::setUp(); 173 174 // we test under useslash conditions 175 $conf['useslash'] = 1; 176 } 177 178 /** 179 * @group slow 180 */ 181 function test_move_page_in_same_ns() { 182 global $ID; 183 $newId = getNS($ID).':new_page'; 184 $this->movedToId = $newId; 185 186 /** @var helper_plugin_move_op $MoveOp */ 187 $MoveOp = plugin_load('helper', 'move_op'); 188 189 $result = $MoveOp->movePage($ID, $this->movedToId); 190 $this->assertTrue($result); 191 192 $newContent = rawWiki($this->movedToId); 193 $expectedContent = <<<EOT 194[[start|start]] 195[[parallel_page|parallel_page]] 196[[.:|.:]] 197[[..current_ns:|..current_ns:]] 198[[..:current_ns:|..:current_ns:]] 199[[..parallel_ns:|..parallel_ns:]] 200[[..:parallel_ns:|..:parallel_ns:]] 201[[..:..:|..:..:]] 202[[..:..:parent_ns:|..:..:parent_ns:]] 203[[parent_ns:new_page|parent_ns:new_page]] 204[[parent_ns/new_page|parent_ns/new_page]] 205[[/start|/start]] 206EOT; 207 $this->assertEquals($expectedContent, $newContent); 208 209 $newContent = rawWiki($this->parentBacklinkingId); 210 $expectedContent = <<<EOT 211[[parent_ns:current_ns:new_page|$this->movedId]] 212[[parent_ns:current_ns:new_page|:$this->movedId]] 213[[.current_ns:new_page|.current_ns:test_page]] 214[[.current_ns:new_page|.:current_ns:test_page]] 215[[.current_ns:new_page|..parent_ns:current_ns:test_page]] 216[[test_page|test_page]] 217[[new_page|new_page]] 218[[ftp://somewhere.com|ftp://somewhere.com]] 219[[http://somewhere.com|http://somewhere.com]] 220 221[[start|start]] 222[[parallel_page|parallel_page]] 223[[.:|.:]] 224[[..current_ns:|..current_ns:]] 225[[..:current_ns:|..:current_ns:]] 226[[..parallel_ns:|..parallel_ns:]] 227[[..:parallel_ns:|..:parallel_ns:]] 228[[..:..:|..:..:]] 229[[..:..:parent_ns:|..:..:parent_ns:]] 230[[parent_ns:new_page|parent_ns:new_page]] 231[[parent_ns/new_page|parent_ns/new_page]] 232[[/start|/start]] 233EOT; 234 $this->assertEquals($expectedContent, $newContent); 235 236 $newContent = rawWiki($this->currentNsBacklinkingId); 237 $expectedContent = <<<EOT 238[[parent_ns:current_ns:new_page|$this->movedId]] 239[[parent_ns:current_ns:new_page|:$this->movedId]] 240[[new_page|..current_ns:test_page]] 241[[new_page|..:current_ns:test_page]] 242[[new_page|test_page]] 243[[new_page|.test_page]] 244[[new_page|.:test_page]] 245[[..test_page|..test_page]] 246[[..:test_page|..:test_page]] 247[[.:..:test_page|.:..:test_page]] 248[[new_page|new_page]] 249[[ftp://somewhere.com|ftp://somewhere.com]] 250[[http://somewhere.com|http://somewhere.com]] 251 252[[start|start]] 253[[parallel_page|parallel_page]] 254[[.:|.:]] 255[[..current_ns:|..current_ns:]] 256[[..:current_ns:|..:current_ns:]] 257[[..parallel_ns:|..parallel_ns:]] 258[[..:parallel_ns:|..:parallel_ns:]] 259[[..:..:|..:..:]] 260[[..:..:parent_ns:|..:..:parent_ns:]] 261[[parent_ns:new_page|parent_ns:new_page]] 262[[parent_ns/new_page|parent_ns/new_page]] 263[[/start|/start]] 264EOT; 265 $this->assertEquals($expectedContent, $newContent); 266 267 $newContent = rawWiki($this->otherBacklinkingId); 268 $expectedContent = <<<EOT 269[[parent_ns:current_ns:new_page|$this->movedId]] 270[[$newId|:$this->movedId]] 271[[.current_ns:test_page|.current_ns:test_page]] 272[[.:current_ns:test_page|.:current_ns:test_page]] 273[[test_page|test_page]] 274[[new_page|new_page]] 275[[ftp://somewhere.com|ftp://somewhere.com]] 276[[http://somewhere.com|http://somewhere.com]] 277 278[[start|start]] 279[[parallel_page|parallel_page]] 280[[.:|.:]] 281[[..current_ns:|..current_ns:]] 282[[..:current_ns:|..:current_ns:]] 283[[..parallel_ns:|..parallel_ns:]] 284[[..:parallel_ns:|..:parallel_ns:]] 285[[..:..:|..:..:]] 286[[..:..:parent_ns:|..:..:parent_ns:]] 287[[parent_ns:new_page|parent_ns:new_page]] 288[[parent_ns/new_page|parent_ns/new_page]] 289[[/start|/start]] 290EOT; 291 $this->assertEquals($expectedContent, $newContent); 292 } 293 294 /** 295 * @group slow 296 */ 297 function test_move_page_to_parallel_ns() { 298 global $ID; 299 $newId = 'parent_ns:parallel_ns:new_page'; 300 $this->movedToId = $newId; 301 302 /** @var helper_plugin_move_op $MoveOp */ 303 $MoveOp = plugin_load('helper', 'move_op'); 304 305 $result = $MoveOp->movePage($ID, $newId); 306 $this->assertTrue($result); 307 308 $newContent = rawWiki($this->movedToId); 309 $expectedContent = <<<EOT 310[[..:current_ns:start|start]] 311[[..:current_ns:parallel_page|parallel_page]] 312[[..:current_ns:|.:]] 313[[..current_ns:|..current_ns:]] 314[[..:current_ns:|..:current_ns:]] 315[[..parallel_ns:|..parallel_ns:]] 316[[..:parallel_ns:|..:parallel_ns:]] 317[[..:..:|..:..:]] 318[[..:..:parent_ns:|..:..:parent_ns:]] 319[[parent_ns:new_page|parent_ns:new_page]] 320[[parent_ns/new_page|parent_ns/new_page]] 321[[/start|/start]] 322EOT; 323 $this->assertEquals($expectedContent, $newContent); 324 325 $newContent = rawWiki($this->parentBacklinkingId); 326 $expectedContent = <<<EOT 327[[parent_ns:parallel_ns:new_page|$this->movedId]] 328[[parent_ns:parallel_ns:new_page|:$this->movedId]] 329[[.parallel_ns:new_page|.current_ns:test_page]] 330[[.parallel_ns:new_page|.:current_ns:test_page]] 331[[.parallel_ns:new_page|..parent_ns:current_ns:test_page]] 332[[test_page|test_page]] 333[[new_page|new_page]] 334[[ftp://somewhere.com|ftp://somewhere.com]] 335[[http://somewhere.com|http://somewhere.com]] 336 337[[start|start]] 338[[parallel_page|parallel_page]] 339[[.:|.:]] 340[[..current_ns:|..current_ns:]] 341[[..:current_ns:|..:current_ns:]] 342[[..parallel_ns:|..parallel_ns:]] 343[[..:parallel_ns:|..:parallel_ns:]] 344[[..:..:|..:..:]] 345[[..:..:parent_ns:|..:..:parent_ns:]] 346[[parent_ns:new_page|parent_ns:new_page]] 347[[parent_ns/new_page|parent_ns/new_page]] 348[[/start|/start]] 349EOT; 350 $this->assertEquals($expectedContent, $newContent); 351 352 $newContent = rawWiki($this->currentNsBacklinkingId); 353 $expectedContent = <<<EOT 354[[parent_ns:parallel_ns:new_page|$this->movedId]] 355[[$newId|:$this->movedId]] 356[[..:parallel_ns:new_page|..current_ns:test_page]] 357[[..:parallel_ns:new_page|..:current_ns:test_page]] 358[[..:parallel_ns:new_page|test_page]] 359[[..:parallel_ns:new_page|.test_page]] 360[[..:parallel_ns:new_page|.:test_page]] 361[[..test_page|..test_page]] 362[[..:test_page|..:test_page]] 363[[.:..:test_page|.:..:test_page]] 364[[new_page|new_page]] 365[[ftp://somewhere.com|ftp://somewhere.com]] 366[[http://somewhere.com|http://somewhere.com]] 367 368[[start|start]] 369[[parallel_page|parallel_page]] 370[[.:|.:]] 371[[..current_ns:|..current_ns:]] 372[[..:current_ns:|..:current_ns:]] 373[[..parallel_ns:|..parallel_ns:]] 374[[..:parallel_ns:|..:parallel_ns:]] 375[[..:..:|..:..:]] 376[[..:..:parent_ns:|..:..:parent_ns:]] 377[[parent_ns:new_page|parent_ns:new_page]] 378[[parent_ns/new_page|parent_ns/new_page]] 379[[/start|/start]] 380EOT; 381 $this->assertEquals($expectedContent, $newContent); 382 383 $newContent = rawWiki($this->otherBacklinkingId); 384 $expectedContent = <<<EOT 385[[parent_ns:parallel_ns:new_page|$this->movedId]] 386[[$newId|:$this->movedId]] 387[[.current_ns:test_page|.current_ns:test_page]] 388[[.:current_ns:test_page|.:current_ns:test_page]] 389[[test_page|test_page]] 390[[new_page|new_page]] 391[[ftp://somewhere.com|ftp://somewhere.com]] 392[[http://somewhere.com|http://somewhere.com]] 393 394[[start|start]] 395[[parallel_page|parallel_page]] 396[[.:|.:]] 397[[..current_ns:|..current_ns:]] 398[[..:current_ns:|..:current_ns:]] 399[[..parallel_ns:|..parallel_ns:]] 400[[..:parallel_ns:|..:parallel_ns:]] 401[[..:..:|..:..:]] 402[[..:..:parent_ns:|..:..:parent_ns:]] 403[[parent_ns:new_page|parent_ns:new_page]] 404[[parent_ns/new_page|parent_ns/new_page]] 405[[/start|/start]] 406EOT; 407 $this->assertEquals($expectedContent, $newContent); 408 } 409 410 /** 411 * @group slow 412 */ 413 function test_move_page_to_parent_ns() { 414 global $ID; 415 416 $newId = 'parent_ns:new_page'; 417 $this->movedToId = $newId; 418 419 /** @var helper_plugin_move_op $MoveOp */ 420 $MoveOp = plugin_load('helper', 'move_op'); 421 422 $result = $MoveOp->movePage($ID, $newId); //parent_ns:current_ns:test_page -> parent_ns:new_page 423 $this->assertTrue($result); 424 425 $newContent = rawWiki($this->movedToId); 426 $expectedContent = <<<EOT 427[[.current_ns:start|start]] 428[[.current_ns:parallel_page|parallel_page]] 429[[.current_ns:|.:]] 430[[.current_ns:|..current_ns:]] 431[[.current_ns:|..:current_ns:]] 432[[.parallel_ns:|..parallel_ns:]] 433[[.parallel_ns:|..:parallel_ns:]] 434[[..:..:|..:..:]] 435[[..:..:parent_ns:|..:..:parent_ns:]] 436[[parent_ns:new_page|parent_ns:new_page]] 437[[parent_ns/new_page|parent_ns/new_page]] 438[[/start|/start]] 439EOT; 440 // Note: ..:..: is not a great link for a page in a namespace 'parent_ns', but it is correctly resolved. 441 $this->assertEquals($expectedContent, $newContent); 442 443 // page is moved to same NS as backlinking page (parent_ns) 444 $newContent = rawWiki($this->parentBacklinkingId); 445 $expectedContent = <<<EOT 446[[parent_ns:new_page|$this->movedId]] 447[[parent_ns:new_page|:$this->movedId]] 448[[new_page|.current_ns:test_page]] 449[[new_page|.:current_ns:test_page]] 450[[new_page|..parent_ns:current_ns:test_page]] 451[[test_page|test_page]] 452[[new_page|new_page]] 453[[ftp://somewhere.com|ftp://somewhere.com]] 454[[http://somewhere.com|http://somewhere.com]] 455 456[[start|start]] 457[[parallel_page|parallel_page]] 458[[.:|.:]] 459[[..current_ns:|..current_ns:]] 460[[..:current_ns:|..:current_ns:]] 461[[..parallel_ns:|..parallel_ns:]] 462[[..:parallel_ns:|..:parallel_ns:]] 463[[..:..:|..:..:]] 464[[..:..:parent_ns:|..:..:parent_ns:]] 465[[parent_ns:new_page|parent_ns:new_page]] 466[[parent_ns/new_page|parent_ns/new_page]] 467[[/start|/start]] 468EOT; 469 $this->assertEquals($expectedContent, $newContent); 470 471 $newContent = rawWiki($this->currentNsBacklinkingId); 472 $expectedContent = <<<EOT 473[[parent_ns:new_page|$this->movedId]] 474[[$newId|:$this->movedId]] 475[[..:new_page|..current_ns:test_page]] 476[[..:new_page|..:current_ns:test_page]] 477[[..:new_page|test_page]] 478[[..:new_page|.test_page]] 479[[..:new_page|.:test_page]] 480[[..test_page|..test_page]] 481[[..:test_page|..:test_page]] 482[[.:..:test_page|.:..:test_page]] 483[[new_page|new_page]] 484[[ftp://somewhere.com|ftp://somewhere.com]] 485[[http://somewhere.com|http://somewhere.com]] 486 487[[start|start]] 488[[parallel_page|parallel_page]] 489[[.:|.:]] 490[[..current_ns:|..current_ns:]] 491[[..:current_ns:|..:current_ns:]] 492[[..parallel_ns:|..parallel_ns:]] 493[[..:parallel_ns:|..:parallel_ns:]] 494[[..:..:|..:..:]] 495[[..:..:parent_ns:|..:..:parent_ns:]] 496[[parent_ns:new_page|parent_ns:new_page]] 497[[parent_ns/new_page|parent_ns/new_page]] 498[[/start|/start]] 499EOT; 500 $this->assertEquals($expectedContent, $newContent); 501 502 $newContent = rawWiki($this->otherBacklinkingId); 503 $expectedContent = <<<EOT 504[[parent_ns:new_page|$this->movedId]] 505[[$newId|:$this->movedId]] 506[[.current_ns:test_page|.current_ns:test_page]] 507[[.:current_ns:test_page|.:current_ns:test_page]] 508[[test_page|test_page]] 509[[new_page|new_page]] 510[[ftp://somewhere.com|ftp://somewhere.com]] 511[[http://somewhere.com|http://somewhere.com]] 512 513[[start|start]] 514[[parallel_page|parallel_page]] 515[[.:|.:]] 516[[..current_ns:|..current_ns:]] 517[[..:current_ns:|..:current_ns:]] 518[[..parallel_ns:|..parallel_ns:]] 519[[..:parallel_ns:|..:parallel_ns:]] 520[[..:..:|..:..:]] 521[[..:..:parent_ns:|..:..:parent_ns:]] 522[[parent_ns:new_page|parent_ns:new_page]] 523[[parent_ns/new_page|parent_ns/new_page]] 524[[/start|/start]] 525EOT; 526 $this->assertEquals($expectedContent, $newContent); 527 } 528 529 /** 530 * Ensure that absolute links stay absolute. See https://github.com/michitux/dokuwiki-plugin-move/pull/6#discussion_r15698440 531 * 532 * @group slow 533 */ 534 function test_move_startpage_of_ns() { 535 saveWikiText('wiki:bar:test', 536 '[[wiki:foo:]]', 'Test setup'); 537 idx_addPage('wiki:bar:test'); 538 saveWikiText('wiki:foo:start', 539 'bar', 'Test setup'); 540 idx_addPage('wiki:foo:start'); 541 542 /** @var helper_plugin_move_op $move */ 543 $move = plugin_load('helper', 'move_op'); 544 $this->assertTrue($move->movePage('wiki:foo:start', 'wiki:foo2:start')); 545 546 $this->assertEquals('[[wiki:foo2:]]', rawWiki('wiki:bar:test')); 547 } 548 549 /** 550 * If the relative part would be too large, create an absolute link instead. 551 * If the original link ended with a colon and the new link also points to a namespace's startpage: keep the colon. 552 * 553 * @group slow 554 */ 555 function test_move_no_long_rel_links_keep_colon() { 556 saveWikiText('wiki:foo:start', '[[..:..:one_ns_up:]]', 'Test setup'); 557 idx_addPage('wiki:foo:start'); 558 559 /** @var helper_plugin_move_op $move */ 560 $move = plugin_load('helper', 'move_op'); 561 562 $this->assertTrue($move->movePage('wiki:foo:start', 'wiki:foo:bar:start')); 563 $this->assertEquals('[[one_ns_up:]]', rawWiki('wiki:foo:bar:start')); 564 565 } 566 567 /** 568 * @covers helper_plugin_move_handler::_nsStartCheck 569 * @group slow 570 */ 571 function test_move_to_thisns_start(){ 572 saveWikiText('wiki:foo:test_page', '[[..:..:bar:]]', 'Test setup'); 573 idx_addPage('wiki:foo:test_page'); 574 saveWikiText('bar:start', 'foo', 'Test setup'); 575 idx_addPage('bar:start'); 576 577 /** @var helper_plugin_move_op $move */ 578 $move = plugin_load('helper', 'move_op'); 579 580 $this->assertTrue($move->movePage('bar:start', 'wiki:foo:start')); 581 $this->assertEquals('[[.:]]', rawWiki('wiki:foo:test_page')); 582 } 583 584 function test_move_ns_in_same_ns() { 585 586 $newNamespace = 'new_ns'; 587 $newPagename = ''; 588 589 $opts = array(); 590 $opts['page_ns'] = 'ns'; 591 $opts['newns'] = 'parent_ns'.':'.$newNamespace; 592 $opts['newname'] = $newPagename; 593 $this->movedToId = $opts['newns'].':'.$newPagename; 594 595 //$this->move->_pm_move_recursive($opts); 596 $this->markTestIncomplete('Test must yet be implemented.'); 597 598 } 599 600 function test_move_start_ns_into_ns_page() { 601 saveWikiText('bugs:start', 'Bug page', 'created'); 602 idx_addPage('bugs:start'); 603 saveWikiText('foo:bugs:test', '[[bugs:start]]', 'created'); 604 idx_addPage('foo:bugs:test'); 605 606 /** @var helper_plugin_move_op $move */ 607 $move = plugin_load('helper', 'move_op'); 608 609 $this->assertTrue($move->movePage('bugs:start', 'bugs')); 610 $this->assertEquals('[[:bugs]]', rawWiki('foo:bugs:test')); 611 612 $this->assertTrue($move->movePage('bugs', 'start')); 613 $this->assertEquals('[[:start]]', rawWiki('foo:bugs:test')); 614 } 615 616 function test_clean_id_move() { 617 saveWikiText('some_space:start', 'Space page', 'created'); 618 idx_addPage('some_space:start'); 619 saveWikiText('foo:bar:test', '[[some space:start]]', 'created'); 620 idx_addPage('foo:bar:test'); 621 622 /** @var helper_plugin_move_op $move */ 623 $move = plugin_load('helper', 'move_op'); 624 625 $this->assertTrue($move->movePage('some_space:start', 'spaceless:start')); 626 $this->assertEquals('[[spaceless:start]]', rawWiki('foo:bar:test')); 627 } 628} 629 630