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