MediaWiki  REL1_19
MovePageTestCase.php
Go to the documentation of this file.
00001 <?php
00002 
00030 class MovePageTestCase extends SeleniumTestCase {
00031 
00032     // Verify move(rename) wiki page
00033     public function testMovePage() {
00034 
00035         $newPage = "mypage99";
00036         $displayName = "Mypage99";
00037 
00038         $this->open( $this->getUrl() .
00039                 '/index.php?title=Main_Page&action=edit' );
00040         $this->type( "searchInput", $newPage );
00041         $this->click( "searchGoButton" );
00042         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00043         $this->click( "link=".$displayName );
00044         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00045         $this->type( SeleniumTestConstants::TEXT_EDITOR, $newPage." text" );
00046         $this->click( SeleniumTestConstants::BUTTON_SAVE );
00047         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00048 
00049         // Verify link 'Move' available
00050         $this->assertTrue($this->isElementPresent( "link=Move" ));
00051 
00052         $this->click( "link=Move" );
00053         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00054 
00055         // Verify correct page name displayed under 'Move Page' field
00056         $this->assertEquals($displayName,
00057                 $this->getText("//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a"));
00058         $movePageName = $this->getText( "//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a" );
00059 
00060         // Verify 'To new title' field has current page name as the default name
00061         $newTitle =  $this->getValue( "wpNewTitle" );
00062         $correct = strstr( $movePageName , $newTitle  );
00063         $this->assertEquals( $correct, true );
00064 
00065         $this->type( "wpNewTitle", $displayName );
00066         $this->click( "wpMove" );
00067         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00068 
00069         // Verify warning message for the same source and destination titles
00070         $this->assertEquals( "Source and destination titles are the same; cannot move a page over itself.",
00071                 $this->getText("//div[@id='bodyContent']/p[4]/strong" ));
00072 
00073         // Verify warning message for the blank title
00074         $this->type( "wpNewTitle", "" );
00075         $this->click( "wpMove" );
00076         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00077 
00078         // Verify warning message for the blank title
00079         $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.",
00080                 $this->getText( "//div[@id='bodyContent']/p[4]/strong" ));
00081 
00082         //  Verify warning messages for the invalid titles
00083         $this->type( "wpNewTitle", "# < > [ ] | { }" );
00084         $this->click( "wpMove" );
00085         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00086         $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.",
00087                 $this->getText( "//div[@id='bodyContent']/p[4]/strong" ));
00088 
00089         $this->type( "wpNewTitle", $displayName."move" );
00090         $this->click( "wpMove" );
00091         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00092 
00093         // Verify move success message displayed correctly
00094         $this->assertEquals( "\"".$displayName."\" has been moved to \"".$displayName."move"."\"",
00095                 $this->getText( "//div[@id='bodyContent']/p[1]/b" ));
00096 
00097         $this->type( "searchInput", $newPage."move" );
00098         $this->click( "searchGoButton" );
00099         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00100 
00101         // Verify search using new page name
00102         $this->assertEquals( $displayName."move", $this->getText( "firstHeading" ));
00103 
00104         $this->type( "searchInput", $newPage );
00105         $this->click( "searchGoButton" );
00106         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00107 
00108         // Verify search using old page name
00109         $redirectPageName = $this->getText( "//*[@id='contentSub']" );
00110         $this->assertEquals( "(Redirected from ".$displayName.")" , $redirectPageName );
00111 
00112         // newpage delete
00113         $this->deletePage( $newPage."move" );
00114         $this->deletePage( $newPage );
00115     }
00116 }
00117