Merge "(bug 42600) (bug 24375) Fix doMaintenance.php exit procedures."
[lhc/web/wiklou.git] / tests / selenium / installer / MediaWikiInstallationCommonFunction.php
1 <?php
2 /**
3 * MediaWikiInstallationCommonFunction
4 *
5 * @file
6 * @ingroup Maintenance
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
9 *
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.
14 *
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.
19 *
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
24 *
25 * @addtogroup Maintenance
26 *
27 */
28
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' );
33
34 class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase {
35 function setUp() {
36 $this->setBrowser( TEST_BROWSER );
37 $this->setBrowserUrl( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" );
38 }
39
40 public function navigateInitialpage() {
41 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" );
42 }
43
44 // Navigate to the 'Language' page
45 public function navigateLanguagePage() {
46 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
47 }
48
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 );
54 }
55
56 // Navigate yo 'Connect to Database' page
57 public function navigateConnetToDatabasePage() {
58 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
59
60 // 'Welcome to MediaWiki!' page
61 $this->click( "submit-continue" );
62 $this->waitForPageToLoad( PAGE_LOAD_TIME );
63
64 // 'Connect to Database' page
65 $this->click( "submit-continue" );
66 $this->waitForPageToLoad( PAGE_LOAD_TIME );
67 }
68
69 // Navigate to the 'Database Settings' page
70 public function navigateDatabaseSettingsPage( $databaseName ) {
71 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
72
73 // 'Welcome to MediaWiki!' page
74 $this->click( "submit-continue" );
75 $this->waitForPageToLoad( PAGE_LOAD_TIME );
76
77 // 'Connect to Database' page
78 $this->click( "submit-continue" );
79 $this->waitForPageToLoad( PAGE_LOAD_TIME );
80
81 $this->type( "mysql_wgDBname", $databaseName );
82 $this->click( "submit-continue" );
83 $this->waitForPageToLoad( PAGE_LOAD_TIME );
84 }
85
86 // Navigate to the 'Name' page
87 public function navigateNamePage( $databaseName ) {
88 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
89
90 // 'Welcome to MediaWiki!' page
91 $this->click( "submit-continue" );
92 $this->waitForPageToLoad( PAGE_LOAD_TIME );
93
94 // 'Connect to Database' page
95 $this->click( "submit-continue" );
96 $this->waitForPageToLoad( PAGE_LOAD_TIME );
97
98 $this->type( "mysql_wgDBname", $databaseName );
99 $this->click( "submit-continue" );
100 $this->waitForPageToLoad( PAGE_LOAD_TIME );
101
102 // Database settings
103 $this->click( "submit-continue" );
104 $this->waitForPageToLoad( PAGE_LOAD_TIME );
105 }
106
107 // Navigate 'Options' page
108 public function navigateOptionsPage( $databaseName ) {
109 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
110
111 // 'Welcome to MediaWiki!' page
112 $this->click( "submit-continue" );
113 $this->waitForPageToLoad( PAGE_LOAD_TIME );
114
115 // 'Connect to Database' page
116 $this->click( "submit-continue" );
117 $this->waitForPageToLoad( PAGE_LOAD_TIME );
118
119 $this->type( "mysql_wgDBname", $databaseName );
120 $this->click( "submit-continue" );
121 $this->waitForPageToLoad( PAGE_LOAD_TIME );
122
123 // Database settings
124 $this->click( "submit-continue" );
125 $this->waitForPageToLoad( PAGE_LOAD_TIME );
126
127 // Name
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 );
133
134 $this->click( "submit-continue" );
135 $this->waitForPageToLoad( PAGE_LOAD_TIME );
136 }
137
138 // Navigate 'Install' page
139 public function navigateInstallPage( $databaseName ) {
140 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
141
142 // 'Welcome to MediaWiki!' page
143 $this->click( "submit-continue" );
144 $this->waitForPageToLoad( PAGE_LOAD_TIME );
145
146 // 'Connect to Database' page
147 $this->click( "submit-continue" );
148 $this->waitForPageToLoad( PAGE_LOAD_TIME );
149
150 $this->type( "mysql_wgDBname", $databaseName );
151 $this->click( "submit-continue" );
152 $this->waitForPageToLoad( PAGE_LOAD_TIME );
153
154 // Database settings
155 $this->click( "submit-continue" );
156 $this->waitForPageToLoad( PAGE_LOAD_TIME );
157
158 // Name
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 );
164
165 $this->click( "submit-continue" );
166 $this->waitForPageToLoad( PAGE_LOAD_TIME );
167
168 // Options page
169 $this->click( "submit-continue" );
170 $this->waitForPageToLoad( PAGE_LOAD_TIME );
171 }
172
173 // Navigate to 'Complete' page
174 public function navigateCompletePage( $databaseName ) {
175 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
176
177 // 'Welcome to MediaWiki!' page
178 $this->click( "submit-continue" );
179 $this->waitForPageToLoad( PAGE_LOAD_TIME );
180
181 // 'Connect to Database' page
182 $this->click( "submit-continue" );
183 $this->waitForPageToLoad( PAGE_LOAD_TIME );
184
185 $this->type( "mysql_wgDBname", $databaseName );
186 $this->click( "submit-continue" );
187 $this->waitForPageToLoad( PAGE_LOAD_TIME );
188
189 // Database settings
190 $this->click( "submit-continue" );
191 $this->waitForPageToLoad( PAGE_LOAD_TIME );
192
193 // Name
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 );
199
200 $this->click( "submit-continue" );
201 $this->waitForPageToLoad( PAGE_LOAD_TIME );
202
203 // Options page
204 $this->click( "submit-continue" );
205 $this->waitForPageToLoad( PAGE_LOAD_TIME );
206
207 // Install page
208 $this->click( "submit-continue" );
209 $this->waitForPageToLoad( PAGE_LOAD_TIME );
210 $this->chooseCancelOnNextConfirmation();
211 }
212
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 );
222 }
223
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 );
228 }
229
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 );
234 }
235
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 );
242 }
243
244 // Verify 'MediaWiki' logo available in the initial screen
245 public function mediaWikiLogoPresentInitialScreen() {
246 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) );
247 }
248
249 // Verify 'MediaWiki' logo available
250 public function mediaWikiLogoPresent() {
251 $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ) );
252 }
253
254 public function completePageSuccessfull() {
255 $this->assertEquals( "Complete!",
256 $this->getText( "//div[@id='bodyContent']/div/div/h2" ) );
257
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" ) );
261 }
262 }