3 * Selenium server manager
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 class MovePageTestCase
extends SeleniumTestCase
{
27 // Verify move(rename) wiki page
28 public function testMovePage() {
29 $newPage = "mypage99";
30 $displayName = "Mypage99";
32 $this->open( $this->getUrl() .
33 '/index.php?title=Main_Page&action=edit' );
34 $this->type( "searchInput", $newPage );
35 $this->click( "searchGoButton" );
36 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
37 $this->click( "link=" . $displayName );
38 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
39 $this->type( SeleniumTestConstants
::TEXT_EDITOR
, $newPage . " text" );
40 $this->click( SeleniumTestConstants
::BUTTON_SAVE
);
41 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
43 // Verify link 'Move' available
44 $this->assertTrue( $this->isElementPresent( "link=Move" ) );
46 $this->click( "link=Move" );
47 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
49 // Verify correct page name displayed under 'Move Page' field
50 $this->assertEquals( $displayName,
51 $this->getText( "//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a" ) );
52 $movePageName = $this->getText( "//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a" );
54 // Verify 'To new title' field has current page name as the default name
55 $newTitle = $this->getValue( "wpNewTitle" );
56 $correct = strstr( $movePageName, $newTitle );
57 $this->assertEquals( $correct, true );
59 $this->type( "wpNewTitle", $displayName );
60 $this->click( "wpMove" );
61 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
63 // Verify warning message for the same source and destination titles
64 $this->assertEquals( "Source and destination titles are the same; cannot move a page over itself.",
65 $this->getText( "//div[@id='bodyContent']/p[4]/strong" ) );
67 // Verify warning message for the blank title
68 $this->type( "wpNewTitle", "" );
69 $this->click( "wpMove" );
70 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
72 // Verify warning message for the blank title
73 $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.",
74 $this->getText( "//div[@id='bodyContent']/p[4]/strong" ) );
76 // Verify warning messages for the invalid titles
77 $this->type( "wpNewTitle", "# < > [ ] | { }" );
78 $this->click( "wpMove" );
79 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
80 $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.",
81 $this->getText( "//div[@id='bodyContent']/p[4]/strong" ) );
83 $this->type( "wpNewTitle", $displayName . "move" );
84 $this->click( "wpMove" );
85 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
87 // Verify move success message displayed correctly
88 $this->assertEquals( "\"" . $displayName . "\" has been moved to \"" . $displayName . "move" . "\"",
89 $this->getText( "//div[@id='bodyContent']/p[1]/b" ) );
91 $this->type( "searchInput", $newPage . "move" );
92 $this->click( "searchGoButton" );
93 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
95 // Verify search using new page name
96 $this->assertEquals( $displayName . "move", $this->getText( "firstHeading" ) );
98 $this->type( "searchInput", $newPage );
99 $this->click( "searchGoButton" );
100 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
102 // Verify search using old page name
103 $redirectPageName = $this->getText( "//*[@id='contentSub']" );
104 $this->assertEquals( "(Redirected from " . $displayName . ")", $redirectPageName );
107 $this->deletePage( $newPage . "move" );
108 $this->deletePage( $newPage );