638470632b0f01d3adc7e6672498d9c6353dc4db
[lhc/web/wiklou.git] / tests / 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( str_replace('//','/',dirname(__FILE__).'/') .'MediaWikiInstallationConfig.php');
31 require_once( str_replace('//','/',dirname(__FILE__).'/') .'MediaWikiInstallationMessage.php');
32 require_once( str_replace('//','/',dirname(__FILE__).'/') .'MediaWikiInstallationVariables.php');
33
34
35 class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase {
36
37 function setUp() {
38 $this->setBrowser( TEST_BROWSER );
39 $this->setBrowserUrl("http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/");
40 }
41
42
43 public function navigateInitialpage() {
44 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/" );
45 }
46
47
48 // Navigate to the 'Language' page
49 public function navigateLanguagePage() {
50 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
51 }
52
53
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 );
59 }
60
61
62 // Navigate yo 'Connect to Database' page
63 public function navigateConnetToDatabasePage() {
64 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
65
66 // 'Welcome to MediaWiki!' page
67 $this->click( "submit-continue" );
68 $this->waitForPageToLoad( PAGE_LOAD_TIME );
69
70 // 'Connect to Database' page
71 $this->click("submit-continue");
72 $this->waitForPageToLoad( PAGE_LOAD_TIME );
73 }
74
75
76 // Navigate to the 'Database Settings' page
77 public function navigateDatabaseSettingsPage( $databaseName ) {
78
79 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
80
81 // 'Welcome to MediaWiki!' page
82 $this->click("submit-continue");
83 $this->waitForPageToLoad( PAGE_LOAD_TIME );
84
85 // 'Connect to Database' page
86 $this->click("submit-continue");
87 $this->waitForPageToLoad( PAGE_LOAD_TIME );
88
89 $this->type("mysql_wgDBname", $databaseName );
90 $this->click( "submit-continue" );
91 $this->waitForPageToLoad( PAGE_LOAD_TIME );
92 }
93
94
95 // Navigate to the 'Name' page
96 public function navigateNamePage( $databaseName ) {
97 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
98
99 // 'Welcome to MediaWiki!' page
100 $this->click( "submit-continue" );
101 $this->waitForPageToLoad( PAGE_LOAD_TIME );
102
103 // 'Connect to Database' page
104 $this->click( "submit-continue" );
105 $this->waitForPageToLoad( PAGE_LOAD_TIME );
106
107 $this->type( "mysql_wgDBname", $databaseName );
108 $this->click( "submit-continue" );
109 $this->waitForPageToLoad( PAGE_LOAD_TIME );
110
111 // Database settings
112 $this->click( "submit-continue" );
113 $this->waitForPageToLoad( PAGE_LOAD_TIME );
114 }
115
116
117 // Navigate 'Options' page
118 public function navigateOptionsPage( $databaseName ) {
119
120 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
121
122 // 'Welcome to MediaWiki!' page
123 $this->click( "submit-continue" );
124 $this->waitForPageToLoad( PAGE_LOAD_TIME );
125
126 // 'Connect to Database' page
127 $this->click( "submit-continue" );
128 $this->waitForPageToLoad( PAGE_LOAD_TIME );
129
130 $this->type( "mysql_wgDBname", $databaseName );
131 $this->click( "submit-continue" );
132 $this->waitForPageToLoad( PAGE_LOAD_TIME );
133
134 // Database settings
135 $this->click( "submit-continue" );
136 $this->waitForPageToLoad( PAGE_LOAD_TIME );
137
138 // Name
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 );
144
145 $this->click( "submit-continue" );
146 $this->waitForPageToLoad( PAGE_LOAD_TIME );
147 }
148
149
150 // Navigate 'Install' page
151 public function navigateInstallPage( $databaseName ) {
152
153 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
154
155 // 'Welcome to MediaWiki!' page
156 $this->click( "submit-continue" );
157 $this->waitForPageToLoad( PAGE_LOAD_TIME );
158
159 // 'Connect to Database' page
160 $this->click( "submit-continue" );
161 $this->waitForPageToLoad( PAGE_LOAD_TIME );
162
163 $this->type( "mysql_wgDBname", $databaseName );
164 $this->click( "submit-continue" );
165 $this->waitForPageToLoad( PAGE_LOAD_TIME );
166
167 // Database settings
168 $this->click( "submit-continue" );
169 $this->waitForPageToLoad( PAGE_LOAD_TIME );
170
171 // Name
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 );
177
178 $this->click( "submit-continue" );
179 $this->waitForPageToLoad( PAGE_LOAD_TIME );
180
181 // Options page
182 $this->click( "submit-continue" );
183 $this->waitForPageToLoad( PAGE_LOAD_TIME );
184 }
185
186
187 // Navigate to 'Complete' page
188 public function navigateCompletePage( $databaseName ) {
189 $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" );
190
191 // 'Welcome to MediaWiki!' page
192 $this->click( "submit-continue" );
193 $this->waitForPageToLoad( PAGE_LOAD_TIME );
194
195 // 'Connect to Database' page
196 $this->click( "submit-continue" );
197 $this->waitForPageToLoad( PAGE_LOAD_TIME );
198
199 $this->type( "mysql_wgDBname", $databaseName );
200 $this->click( "submit-continue" );
201 $this->waitForPageToLoad( PAGE_LOAD_TIME );
202
203 // Database settings
204 $this->click( "submit-continue" );
205 $this->waitForPageToLoad( PAGE_LOAD_TIME );
206
207 // Name
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 );
213
214 $this->click( "submit-continue" );
215 $this->waitForPageToLoad( PAGE_LOAD_TIME );
216
217 // Options page
218 $this->click( "submit-continue" );
219 $this->waitForPageToLoad( PAGE_LOAD_TIME );
220
221 // Install page
222 $this->click( "submit-continue" );
223 $this->waitForPageToLoad( PAGE_LOAD_TIME );
224 $this->chooseCancelOnNextConfirmation();
225 }
226
227
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);
237 }
238
239
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 );
244 }
245
246
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 );
251 }
252
253
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 );
260 }
261
262
263 // Verify 'MediaWiki' logo available in the initial screen
264 public function mediaWikiLogoPresentInitialScreen() {
265 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ));
266 }
267
268
269 // Verify 'MediaWiki' logo available
270 public function mediaWikiLogoPresent() {
271 $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ));
272 }
273
274
275 public function completePageSuccessfull() {
276 $this->assertEquals( "Complete!",
277 $this->getText( "//div[@id='bodyContent']/div/div/h2" ));
278
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" ));
282 }
283 }