3 * MediaWikiInstallationCommonFunction
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
25 * @addtogroup Maintenance
29 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
30 require_once ( dirname( __FILE__
) . '/MediaWikiInstallationConfig.php' );
31 require_once ( dirname(__FILE__
) . '/MediaWikiInstallationMessage.php' );
32 require_once ( dirname(__FILE__
) . '/MediaWikiInstallationVariables.php');
35 class MediaWikiInstallationCommonFunction
extends PHPUnit_Extensions_SeleniumTestCase
{
38 $this->setBrowser( TEST_BROWSER
);
39 $this->setBrowserUrl("http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/");
43 public function navigateInitialpage() {
44 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/" );
48 // Navigate to the 'Language' page
49 public function navigateLanguagePage() {
50 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
54 // Navigate to the 'Welcome to MediaWiki' page
55 public function navigateWelcometoMediaWikiPage() {
56 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
57 $this->click( "submit-continue ");
58 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
62 // Navigate yo 'Connect to Database' page
63 public function navigateConnetToDatabasePage() {
64 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
66 // 'Welcome to MediaWiki!' page
67 $this->click( "submit-continue" );
68 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
70 // 'Connect to Database' page
71 $this->click("submit-continue");
72 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
76 // Navigate to the 'Database Settings' page
77 public function navigateDatabaseSettingsPage( $databaseName ) {
79 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
81 // 'Welcome to MediaWiki!' page
82 $this->click("submit-continue");
83 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
85 // 'Connect to Database' page
86 $this->click("submit-continue");
87 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
89 $this->type("mysql_wgDBname", $databaseName );
90 $this->click( "submit-continue" );
91 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
95 // Navigate to the 'Name' page
96 public function navigateNamePage( $databaseName ) {
97 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
99 // 'Welcome to MediaWiki!' page
100 $this->click( "submit-continue" );
101 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
103 // 'Connect to Database' page
104 $this->click( "submit-continue" );
105 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
107 $this->type( "mysql_wgDBname", $databaseName );
108 $this->click( "submit-continue" );
109 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
112 $this->click( "submit-continue" );
113 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
117 // Navigate 'Options' page
118 public function navigateOptionsPage( $databaseName ) {
120 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
122 // 'Welcome to MediaWiki!' page
123 $this->click( "submit-continue" );
124 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
126 // 'Connect to Database' page
127 $this->click( "submit-continue" );
128 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
130 $this->type( "mysql_wgDBname", $databaseName );
131 $this->click( "submit-continue" );
132 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
135 $this->click( "submit-continue" );
136 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
139 $this->type( "config_wgSitename", NAME_OF_WIKI
);
140 $this->type( "config__AdminName", ADMIN_USER_NAME
);
141 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
142 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
143 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
145 $this->click( "submit-continue" );
146 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
150 // Navigate 'Install' page
151 public function navigateInstallPage( $databaseName ) {
153 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
155 // 'Welcome to MediaWiki!' page
156 $this->click( "submit-continue" );
157 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
159 // 'Connect to Database' page
160 $this->click( "submit-continue" );
161 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
163 $this->type( "mysql_wgDBname", $databaseName );
164 $this->click( "submit-continue" );
165 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
168 $this->click( "submit-continue" );
169 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
172 $this->type( "config_wgSitename", NAME_OF_WIKI
);
173 $this->type( "config__AdminName", ADMIN_USER_NAME
);
174 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
175 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
176 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
178 $this->click( "submit-continue" );
179 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
182 $this->click( "submit-continue" );
183 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
187 // Navigate to 'Complete' page
188 public function navigateCompletePage( $databaseName ) {
189 $this->open( "http://".HOST_NAME
.":".PORT
."/".DIRECTORY_NAME
."/config/index.php" );
191 // 'Welcome to MediaWiki!' page
192 $this->click( "submit-continue" );
193 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
195 // 'Connect to Database' page
196 $this->click( "submit-continue" );
197 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
199 $this->type( "mysql_wgDBname", $databaseName );
200 $this->click( "submit-continue" );
201 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
204 $this->click( "submit-continue" );
205 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
208 $this->type( "config_wgSitename", NAME_OF_WIKI
);
209 $this->type( "config__AdminName", ADMIN_USER_NAME
);
210 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
211 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
212 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
214 $this->click( "submit-continue" );
215 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
218 $this->click( "submit-continue" );
219 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
222 $this->click( "submit-continue" );
223 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
224 $this->chooseCancelOnNextConfirmation();
228 // Complete the Name page fields
229 public function completeNamePage() {
230 $this->type( "config_wgSitename", NAME_OF_WIKI
);
231 $this->type( "config__AdminName", ADMIN_USER_NAME
);
232 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
233 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
234 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
235 $this->click( "submit-continue" );
236 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
240 // Clicking on the 'Continue' button in any MediaWiki page
241 public function clickContinueButton() {
242 $this->click( "submit-continue" );
243 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
247 // Clicking on the 'Back' button in any MediaWiki page
248 public function clickBackButton() {
249 $this->click( "submit-back" );
250 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
254 // Restarting the installation
255 public function restartInstallation() {
256 $this->click( "link=Restart installation" );
257 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
258 $this->click( "submit-restart" );
259 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
263 // Verify 'MediaWiki' logo available in the initial screen
264 public function mediaWikiLogoPresentInitialScreen() {
265 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ));
269 // Verify 'MediaWiki' logo available
270 public function mediaWikiLogoPresent() {
271 $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ));
275 public function completePageSuccessfull() {
276 $this->assertEquals( "Complete!",
277 $this->getText( "//div[@id='bodyContent']/div/div/h2" ));
279 // 'Congratulations!' text should be available in the 'Complete!' page.
280 $this->assertEquals( "Congratulations!",
281 $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" ));