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