d4d3b1f2a65538c69b3abb7151886d7cd0904694
[lhc/web/wiklou.git] / maintenance / tests / selenium / suites / MovePageTestCase.php
1 <?php
2
3 /**
4 * Selenium server manager
5 *
6 * @file
7 * @ingroup Maintenance
8 * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com>
9 * http://citizendium.org/
10 *
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.
15 *
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.
20 *
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
25 *
26 * @addtogroup Maintenance
27 *
28 */
29
30 class MovePageTestCase extends SeleniumTestCase {
31
32 // Verify move(rename) wiki page
33 public function testMovePage() {
34
35 $newPage = "mypage99";
36 $displayName = "Mypage99";
37
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( "30000" );
43 $this->click( "link=".$displayName );
44 $this->waitForPageToLoad( "60000" );
45 $this->type( "wpTextbox1", $newPage." text" );
46 $this->click( "wpSave" );
47 $this->waitForPageToLoad( "60000" );
48
49 // Verify link 'Move' available
50 $this->assertTrue($this->isElementPresent( "link=Move" ));
51
52 $this->click( "link=Move" );
53 $this->waitForPageToLoad( "30000" );
54
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" );
59
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 );
64
65 $this->type( "wpNewTitle", $displayName );
66 $this->click( "wpMove" );
67 $this->waitForPageToLoad( "30000" );
68
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" ));
72
73 // Verify warning message for the blank title
74 $this->type( "wpNewTitle", "" );
75 $this->click( "wpMove" );
76 $this->waitForPageToLoad( "30000" );
77
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" ));
81
82 // Verify warning messages for the invalid titles
83 $this->type( "wpNewTitle", "# < > [ ] | { }" );
84 $this->click( "wpMove" );
85 $this->waitForPageToLoad( "30000" );
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" ));
88
89 $this->type( "wpNewTitle", $displayName."move" );
90 $this->click( "wpMove" );
91 $this->waitForPageToLoad( "30000" );
92
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" ));
96
97 $this->type( "searchInput", $newPage."move" );
98 $this->click( "searchGoButton" );
99 $this->waitForPageToLoad( "30000" );
100
101 // Verify search using new page name
102 $this->assertEquals( $displayName."move", $this->getText( "firstHeading" ));
103
104 $this->type( "searchInput", $newPage );
105 $this->click( "searchGoButton" );
106 $this->waitForPageToLoad( "30000" );
107
108 // Verify search using old page name
109 $redirectPageName = $this->getText( "//*[@id='contentSub']" );
110 $this->assertEquals( "(Redirected from ".$displayName.")" , $redirectPageName );
111
112 // newpage delete
113 $this->deletePage( $newPage."move" );
114 $this->deletePage( $newPage );
115 }
116 }
117