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