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 ( __DIR__
. '/MediaWikiInstallationConfig.php' );
31 require_once ( __DIR__
. '/MediaWikiInstallationMessage.php' );
32 require_once ( __DIR__
. '/MediaWikiInstallationVariables.php' );
34 class MediaWikiInstallationCommonFunction
extends PHPUnit_Extensions_SeleniumTestCase
{
36 $this->setBrowser( TEST_BROWSER
);
37 $this->setBrowserUrl( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/" );
40 public function navigateInitialpage() {
41 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/" );
44 // Navigate to the 'Language' page
45 public function navigateLanguagePage() {
46 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
49 // Navigate to the 'Welcome to MediaWiki' page
50 public function navigateWelcometoMediaWikiPage() {
51 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
52 $this->click( "submit-continue " );
53 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
56 // Navigate yo 'Connect to Database' page
57 public function navigateConnetToDatabasePage() {
58 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
60 // 'Welcome to MediaWiki!' page
61 $this->click( "submit-continue" );
62 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
64 // 'Connect to Database' page
65 $this->click( "submit-continue" );
66 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
69 // Navigate to the 'Database Settings' page
70 public function navigateDatabaseSettingsPage( $databaseName ) {
71 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
73 // 'Welcome to MediaWiki!' page
74 $this->click( "submit-continue" );
75 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
77 // 'Connect to Database' page
78 $this->click( "submit-continue" );
79 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
81 $this->type( "mysql_wgDBname", $databaseName );
82 $this->click( "submit-continue" );
83 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
86 // Navigate to the 'Name' page
87 public function navigateNamePage( $databaseName ) {
88 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
90 // 'Welcome to MediaWiki!' page
91 $this->click( "submit-continue" );
92 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
94 // 'Connect to Database' page
95 $this->click( "submit-continue" );
96 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
98 $this->type( "mysql_wgDBname", $databaseName );
99 $this->click( "submit-continue" );
100 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
103 $this->click( "submit-continue" );
104 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
107 // Navigate 'Options' page
108 public function navigateOptionsPage( $databaseName ) {
109 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
111 // 'Welcome to MediaWiki!' page
112 $this->click( "submit-continue" );
113 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
115 // 'Connect to Database' page
116 $this->click( "submit-continue" );
117 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
119 $this->type( "mysql_wgDBname", $databaseName );
120 $this->click( "submit-continue" );
121 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
124 $this->click( "submit-continue" );
125 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
128 $this->type( "config_wgSitename", NAME_OF_WIKI
);
129 $this->type( "config__AdminName", ADMIN_USER_NAME
);
130 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
131 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
132 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
134 $this->click( "submit-continue" );
135 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
138 // Navigate 'Install' page
139 public function navigateInstallPage( $databaseName ) {
140 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
142 // 'Welcome to MediaWiki!' page
143 $this->click( "submit-continue" );
144 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
146 // 'Connect to Database' page
147 $this->click( "submit-continue" );
148 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
150 $this->type( "mysql_wgDBname", $databaseName );
151 $this->click( "submit-continue" );
152 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
155 $this->click( "submit-continue" );
156 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
159 $this->type( "config_wgSitename", NAME_OF_WIKI
);
160 $this->type( "config__AdminName", ADMIN_USER_NAME
);
161 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
162 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
163 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
165 $this->click( "submit-continue" );
166 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
169 $this->click( "submit-continue" );
170 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
173 // Navigate to 'Complete' page
174 public function navigateCompletePage( $databaseName ) {
175 $this->open( "http://" . HOST_NAME
. ":" . PORT
. "/" . DIRECTORY_NAME
. "/config/index.php" );
177 // 'Welcome to MediaWiki!' page
178 $this->click( "submit-continue" );
179 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
181 // 'Connect to Database' page
182 $this->click( "submit-continue" );
183 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
185 $this->type( "mysql_wgDBname", $databaseName );
186 $this->click( "submit-continue" );
187 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
190 $this->click( "submit-continue" );
191 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
194 $this->type( "config_wgSitename", NAME_OF_WIKI
);
195 $this->type( "config__AdminName", ADMIN_USER_NAME
);
196 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
197 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
198 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
200 $this->click( "submit-continue" );
201 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
204 $this->click( "submit-continue" );
205 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
208 $this->click( "submit-continue" );
209 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
210 $this->chooseCancelOnNextConfirmation();
213 // Complete the Name page fields
214 public function completeNamePage() {
215 $this->type( "config_wgSitename", NAME_OF_WIKI
);
216 $this->type( "config__AdminName", ADMIN_USER_NAME
);
217 $this->type( "config__AdminPassword", ADMIN_PASSWORD
);
218 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD
);
219 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS
);
220 $this->click( "submit-continue" );
221 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
224 // Clicking on the 'Continue' button in any MediaWiki page
225 public function clickContinueButton() {
226 $this->click( "submit-continue" );
227 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
230 // Clicking on the 'Back' button in any MediaWiki page
231 public function clickBackButton() {
232 $this->click( "submit-back" );
233 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
236 // Restarting the installation
237 public function restartInstallation() {
238 $this->click( "link=Restart installation" );
239 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
240 $this->click( "submit-restart" );
241 $this->waitForPageToLoad( PAGE_LOAD_TIME
);
244 // Verify 'MediaWiki' logo available in the initial screen
245 public function mediaWikiLogoPresentInitialScreen() {
246 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) );
249 // Verify 'MediaWiki' logo available
250 public function mediaWikiLogoPresent() {
251 $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ) );
254 public function completePageSuccessfull() {
255 $this->assertEquals( "Complete!",
256 $this->getText( "//div[@id='bodyContent']/div/div/h2" ) );
258 // 'Congratulations!' text should be available in the 'Complete!' page.
259 $this->assertEquals( "Congratulations!",
260 $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" ) );