phpcs: More require/include is not a function
[lhc/web/wiklou.git] / tests / selenium / installer / MediaWikiUserInterfaceTestCase.php
1 <?php
2 /**
3 * MediaWikiUserInterfaceTestCase
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
26 require_once __DIR__ . '/MediaWikiInstallationCommonFunction.php';
27
28 /**
29 * Test Case ID : 18 - 27 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
30 * Test Case Name : UI of MediaWiki initial/ Language/ Welcome to MediaWiki!/ Connect to database/
31 * Database settings/ Name/ Options/ Install/ Complete/ Restart Inslation pages
32 * Version : MediaWiki 1.18alpha
33 */
34 class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction {
35 function setUp() {
36 parent::setUp();
37 }
38
39 public function testInitialPageUI() {
40
41 parent::navigateInitialpage();
42
43 // MediaWiki logo available
44 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) );
45
46 // 'MediaWiki 1.18alpha' text available
47 $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" ) );
48
49 // 'LocalSettings.php not found.' text available
50 $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" ) );
51
52 // 'Please set up the wiki first' text available
53 $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" ) );
54
55 // 'set up the wiki' link available
56 $this->assertTrue( $this->isElementPresent( "link=set up the wiki" ) );
57 }
58
59 public function testlanguagePageUI() {
60 parent::navigateLanguagePage();
61
62 // Verify 'Language' heading
63 $this->assertEquals( "Language", $this->getText( LINK_DIV . "h2" ) );
64
65 // 'Your language' label available
66 $this->assertEquals( "Your language:",
67 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
68
69 // 'Your language' dropdown available
70 $this->assertTrue( $this->isElementPresent( "UserLang" ) );
71
72 // 'Wiki language' label available
73 $this->assertEquals( "Wiki language:",
74 $this->getText( LINK_FORM . "div[2]/div[1]/label" ) );
75
76 // 'Wiki language' dropdown available
77 $this->assertTrue( $this->isElementPresent( "ContLang" ) );
78 }
79
80 public function testWelcometoMediaWikiUI() {
81 parent::navigateWelcometoMediaWikiPage();
82
83 // Verify 'Welcome to MediaWiki!' heading
84 $this->assertEquals( "Welcome to MediaWiki!",
85 $this->getText( LINK_DIV . "h2" ) );
86
87 // Verify environment ok text displayed.
88 $this->assertEquals( "The environment has been checked.You can install MediaWiki.",
89 $this->getText( LINK_DIV . "div[6]/span" ) );
90 }
91
92 public function testConnectToDatabaseUI() {
93 parent::navigateConnetToDatabasePage();
94
95 // 'MYSQL radio button available
96 $this->assertEquals( "MySQL",
97 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[1]/label" ) );
98 $this->assertTrue( $this->isElementPresent( LINK_FORM . "div[2]/div[2]/ul/li[1]" ) );
99
100 // 'SQLite' radio button available
101 $this->assertTrue( $this->isElementPresent( LINK_FORM . "div[2]/div[2]/ul/li[2]" ) );
102 $this->assertEquals( "SQLite", $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[2]/label " ) );
103
104 // 'Database host' label available
105 $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" ) );
106
107 // 'Database host' text box default to 'localhost'
108 $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" ) );
109
110 // 'Identify this wiki' section available
111 $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) );
112
113 // 'Identify this wiki' label available
114 $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) );
115
116 // 'Database name' lable available
117 $this->assertEquals( "Database name:",
118 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" ) );
119
120 // Verify 'Database name:' text box is default to 'my_wiki'
121 $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" ) );
122
123 // Verify 'Database table prefix:' label available
124 $this->assertEquals( "Database table prefix:",
125 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" ) );
126
127 // 'User account for installation' section available
128 $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) );
129
130 // 'User account for installation' label available
131 $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) );
132
133 // 'Database username' label available
134 $this->assertEquals( "Database username:",
135 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" ) );
136
137 // 'Database username' text box defaults to 'root'
138 $this->assertEquals( "root", $this->getValue( "mysql__InstallUser" ) );
139
140 // 'Database password' label available
141 $this->assertEquals( "Database password:",
142 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" ) );
143 }
144
145 public function testDatabaseSettingsUI() {
146 $databaseName = DB_NAME_PREFIX . "_db_settings_UI";
147 parent::navigateDatabaseSettingsPage( $databaseName );
148
149 // 'Database settings' text available.
150 $this->assertEquals( "Database settings", $this->getText( LINK_DIV . "h2" ) );
151
152 // 'Database account for web access' section available
153 $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) );
154
155 // 'Database account for web access' label available
156 $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM . "fieldset/legend" ) );
157
158 // 'Use the same account as for installation' check box available
159 $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM . "fieldset/div[1]/label" ) );
160
161 // 'Use the same account as for installation' check box is selected by default
162 $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ) );
163
164 // 'Use the same account as for installation' check box deselected
165 $this->click( "mysql__SameAccount" );
166
167 // verify 'Use the same account as for installation' check box is not selected
168 $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" ) );
169
170 // 'Database username' label available
171 $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" ) );
172
173 // 'Database username' text box is default to the 'wikiuser'
174 $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" ) );
175
176 // 'Database password' label available
177 $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" ) );
178
179 // 'Create the account if it does not already exist' label available
180 $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" ) );
181
182 // 'Create the account if it does not already exist' check box is not selected by default
183 $this->assertEquals( "off", $this->getValue( "mysql__CreateDBAccount" ) );
184
185 // 'Create the account if it does not already exist' check box selected
186 $this->click( "mysql__CreateDBAccount" );
187
188 // Verify 'Create the account if it does not already exist' check box is selected
189 $this->assertEquals( "on", $this->getValue( "mysql__CreateDBAccount" ) );
190 $this->click( "mysql__SameAccount" );
191 $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ) );
192
193 // 'Storage engine' label available
194 $this->assertEquals( "Storage engine:",
195 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
196
197 // 'InnoDB' label available
198 $this->assertEquals( "InnoDB",
199 $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[1]/label" ) );
200
201 // 'InnoDB' radio button available
202 $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" ) );
203
204 // 'MyISAM' label available
205 $this->assertEquals( "MyISAM", $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[2]/label" ) );
206
207 // 'MyISAM' radio button available
208 $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_MyISAM" ) );
209
210 // 'Database character set' label available
211 $this->assertEquals( "Database character set:",
212 $this->getText( LINK_FORM . "div[3]/div[1]/label" ) );
213
214 // 'Binary' radio button available
215 $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" ) );
216
217 // 'Binary' radio button available
218 $this->assertEquals( "Binary", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[1]/label" ) );
219
220 // 'UTF-8' radio button available
221 $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" ) );
222
223 // 'UTF-8' label available
224 $this->assertEquals( "UTF-8", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[2]/label" ) );
225
226 // 'Binary' radio button is selected
227 $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" ) );
228 }
229
230 public function testNamePageUI() {
231 $databaseName = DB_NAME_PREFIX . "_name_UI";
232 parent::navigateNamePage( $databaseName );
233
234 // 'Name of wiki' text box available
235 $this->assertEquals( "Name of wiki:",
236 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
237
238 $this->assertTrue( $this->isElementPresent( "config_wgSitename" ) );
239
240 // 'Project namespace' label available
241 $this->assertEquals( "Project namespace:",
242 $this->getText( LINK_FORM . "div[2]/div[1]/label" ) );
243
244 // 'Same as the wiki name' radio button available
245 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" ) );
246
247 // 'Project' radio button available
248 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" ) );
249
250 // 'Project' radio button available
251 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" ) );
252
253 // 'Same as the wiki name' label available
254 $this->assertEquals( "Same as the wiki name:",
255 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[1]/label" ) );
256
257 // 'Project' label available
258 $this->assertEquals( "Project",
259 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[2]/label" ) );
260
261 // 'Project' label available
262 $this->assertEquals( "Other (specify)",
263 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[3]/label" ) );
264
265 // 'Same as the wiki name' radio button selected by default
266 $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" ) );
267
268 // 'Administrator account' section available
269 $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) );
270
271 // 'Administrator account' label available
272 $this->assertEquals( "Administrator account",
273 $this->getText( LINK_FORM . "fieldset/legend" ) );
274
275 // 'Your Name' label available
276 $this->assertEquals( "Your name:",
277 $this->getText( LINK_FORM . "fieldset/div[1]/div[1]/label" ) );
278
279 // 'Your Name' text box available
280 $this->assertTrue( $this->isElementPresent( "config__AdminName" ) );
281
282 // 'Password' label available
283 $this->assertEquals( "Password:",
284 $this->getText( LINK_FORM . "fieldset/div[2]/div[1]/label" ) );
285
286 // 'Password' text box available
287 $this->assertTrue( $this->isElementPresent( "config__AdminPassword" ) );
288
289 // 'Password again' label available
290 $this->assertEquals( "Password again:",
291 $this->getText( LINK_FORM . "fieldset/div[3]/div[1]/label" ) );
292
293 // 'Password again' text box available
294 $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" ) );
295
296 // 'Email address' label avaialble
297 $this->assertEquals( "E-mail address:",
298 $this->getText( LINK_FORM . "fieldset/div[4]/div[1]/label" ) );
299
300 // 'Email address' text box available
301 $this->assertTrue( $this->isElementPresent( "config__AdminEmail" ) );
302
303 // Message displayed
304 $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.",
305 $this->getText( LINK_FORM . "/div[4]/div[2]/p" ) );
306
307 // 'Ask me more questions.' radio button available
308 $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" ) );
309
310 // 'Ask me more questions.' label available
311 $this->assertEquals( "Ask me more questions.",
312 $this->getText( LINK_FORM . "div[5]/div[2]/ul/li[1]/label" ) );
313
314 // 'I'm bored already, just install the wiki' radio button is avaiable
315 $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" ) );
316
317 // 'I'm bored already, just install the wiki' label available
318 $this->assertEquals( "I'm bored already, just install the wiki.",
319 $this->getText( LINK_FORM . "div[5]/div[2]/ul/li[2]/label" ) );
320
321 // 'Ask me more questions.' radio button is default selected
322 $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" ) );
323 }
324
325 public function testOptionPageUI() {
326 $databaseName = DB_NAME_PREFIX . "_options_UI";
327 parent::navigateOptionsPage( $databaseName );
328
329 // 'Options' label available
330 $this->assertEquals( "Options", $this->getText( LINK_DIV . "h2" ) );
331
332 // 'Return e-mail address' label available
333 $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" ) );
334
335 // 'Return e-mail address' text box available
336 $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" ) );
337
338 // Text 'apache@localhost' is default value of the 'Return e-mail address' text box
339 $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" ) );
340
341 // 'Logo URL' label available
342 $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM . "fieldset[2]/div[3]/div[1]/label" ) );
343
344 // 'Logo URL' text box available
345 $this->assertTrue( $this->isElementPresent( "config_wgLogo" ) );
346
347 // Correct path available in the 'Logo URL' text box
348 $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" ) );
349
350 // 'Enable file uploads' radio button available
351 $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" ) );
352
353 // 'Enable file uploads' label available
354 $this->assertEquals( "Enable file uploads",
355 $this->getText( LINK_FORM . "fieldset[2]/div[1]/label" ) );
356
357 // 'Enable file uploads' check box is not selected
358 $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" ) );
359
360 $this->click( "config_wgEnableUploads" );
361
362 // 'Directory for deleted files' label available
363 $this->assertEquals( "Directory for deleted files:",
364 $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" ) );
365
366 // 'Directory for deleted files' text box available
367 $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" ) );
368
369 // Correct path available in the 'Directory for deleted files' text box
370 $this->assertEquals( "C:\\wamp\\www\\" . DIRECTORY_NAME . "/images/deleted",
371 $this->getValue( "config_wgDeletedDirectory" ) );
372 }
373
374 public function testInstallPageUI() {
375 $databaseName = DB_NAME_PREFIX . "_install_UI";
376 parent::navigateInstallPage( $databaseName );
377
378 // Verify installation done messages display
379 $this->assertEquals( "Setting up database... done",
380 $this->getText( LINK_FORM . "ul/li[1]" ) );
381 $this->assertEquals( "Creating tables... done",
382 $this->getText( LINK_FORM . "ul/li[2]" ) );
383 $this->assertEquals( "Creating database user... done",
384 $this->getText( LINK_FORM . "ul/li[3]" ) );
385 $this->assertEquals( "Populating default interwiki table... done",
386 $this->getText( LINK_FORM . "ul/li[4]" ) );
387 $this->assertEquals( "Generating secret key... done",
388 $this->getText( LINK_FORM . "ul/li[5]" ) );
389 $this->assertEquals( "Generating default upgrade key... done",
390 $this->getText( LINK_FORM . "ul/li[6]" ) );
391 $this->assertEquals( "Creating administrator user account... done",
392 $this->getText( LINK_FORM . "ul/li[7]" ) );
393 $this->assertEquals( "Creating main page with default content... done",
394 $this->getText( LINK_FORM . "ul/li[8]" ) );
395 }
396
397 public function testCompletePageUI() {
398 $databaseName = DB_NAME_PREFIX . "_complete_UI";
399 parent::navigateCompletePage( $databaseName );
400
401 // 'Congratulations!' text display
402 $this->assertEquals( "Congratulations!",
403 $this->getText( LINK_FORM . "div[1]/div[2]/p[1]/b" ) );
404 // 'LocalSettings.php' generated message display
405 $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.",
406 $this->getText( LINK_FORM . "div[1]/div[2]/p[2]" ) );
407
408 // 'Download LocalSettings.php'' link available
409 $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" ) );
410
411 // 'enter your wiki' link available
412 $this->assertTrue( $this->isElementPresent( "link=Folder/index.php enter your wiki" ) );
413 }
414
415 public function testRestartInstallation() {
416 parent::navigateConnetToDatabasePage();
417 $this->click( "link=Restart installation" );
418 $this->waitForPageToLoad( PAGE_LOAD_TIME );
419
420 // Restart installation' label should be available.
421 $this->assertEquals( "Restart installation", $this->getText( LINK_DIV . "h2" ) );
422
423 //'Do you want to clear all saved data that you have entered and restart the installation process?' label available
424 $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?",
425 $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" ) );
426 // 'Back' button available
427 $this->assertTrue( $this->isElementPresent( "submit-back" ) );
428
429 // 'Restart' button available
430 $this->assertTrue( $this->isElementPresent( "submit-restart" ) );
431 }
432
433 public function testMediaWikiLogoAvailability() {
434 $databaseName = DB_NAME_PREFIX . "_mediawiki_logo";
435 parent::navigateInitialpage();
436 parent::mediaWikiLogoPresentInitialScreen();
437 $this->click( "link=set up the wiki" );
438 $this->waitForPageToLoad( PAGE_LOAD_TIME );
439
440 // 'Language' page
441 parent::mediaWikiLogoPresent();
442 parent::clickContinueButton();
443
444 // 'Welcome to MediaWiki' page
445 parent::mediaWikiLogoPresent();
446 parent::clickContinueButton();
447
448 // 'Connet to database' page
449 parent::mediaWikiLogoPresent();
450 $this->type( "mysql_wgDBname", $databaseName );
451 parent::clickContinueButton();
452
453 // 'Database setting' page
454 parent::mediaWikiLogoPresent();
455 parent::clickContinueButton();
456
457 // 'Name' page
458 parent::mediaWikiLogoPresent();
459 parent::completeNamePage();
460 parent::clickContinueButton();
461
462 // 'Options' page
463 parent::mediaWikiLogoPresent();
464 parent::clickContinueButton();
465
466 // 'Install' page
467 parent::mediaWikiLogoPresent();
468 }
469
470 public function testRightFramework() {
471 parent::navigateLanguagePage();
472 // Verfy right framework texts display
473 $this->assertEquals( "Language",
474 $this->getText( LINK_RIGHT_FRAMEWORK . "li[1]" ) );
475 $this->assertEquals( "Existing wiki",
476 $this->getText( LINK_RIGHT_FRAMEWORK . "li[2]" ) );
477 $this->assertEquals( "Welcome to MediaWiki!",
478 $this->getText( LINK_RIGHT_FRAMEWORK . "li[3]" ) );
479 $this->assertEquals( "Connect to database",
480 $this->getText( LINK_RIGHT_FRAMEWORK . "li[4]" ) );
481 $this->assertEquals( "Upgrade existing installation",
482 $this->getText( LINK_RIGHT_FRAMEWORK . "li[5]" ) );
483 $this->assertEquals( "Database settings",
484 $this->getText( LINK_RIGHT_FRAMEWORK . "li[6]" ) );
485 $this->assertEquals( "Name",
486 $this->getText( LINK_RIGHT_FRAMEWORK . "li[7]" ) );
487 $this->assertEquals( "Options",
488 $this->getText( LINK_RIGHT_FRAMEWORK . "li[8]" ) );
489 $this->assertEquals( "Install",
490 $this->getText( LINK_RIGHT_FRAMEWORK . "li[9]" ) );
491 $this->assertEquals( "Complete!",
492 $this->getText( LINK_RIGHT_FRAMEWORK . "li[10]/span" ) );
493 }
494 }