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