(bug 47950) Fix IndexPager detection of "is first" state
[mediawiki.git] / tests / selenium / installer / MediaWikiUserInterfaceTestCase.php
blob97331523cac6e9041ebc612b08be0782e138a1e4
1 <?php
2 /**
3 * MediaWikiUserInterfaceTestCase
5 * @file
6 * @ingroup Maintenance
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
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.
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.
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
26 require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' );
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
34 class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction {
35 function setUp() {
36 parent::setUp();
39 public function testInitialPageUI() {
41 parent::navigateInitialpage();
43 // MediaWiki logo available
44 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) );
46 // 'MediaWiki 1.18alpha' text available
47 $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" ) );
49 // 'LocalSettings.php not found.' text available
50 $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" ) );
52 // 'Please set up the wiki first' text available
53 $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" ) );
55 // 'set up the wiki' link available
56 $this->assertTrue( $this->isElementPresent( "link=set up the wiki" ) );
59 public function testlanguagePageUI() {
60 parent::navigateLanguagePage();
62 // Verify 'Language' heading
63 $this->assertEquals( "Language", $this->getText( LINK_DIV . "h2" ) );
65 // 'Your language' label available
66 $this->assertEquals( "Your language:",
67 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
69 // 'Your language' dropdown available
70 $this->assertTrue( $this->isElementPresent( "UserLang" ) );
72 // 'Wiki language' label available
73 $this->assertEquals( "Wiki language:",
74 $this->getText( LINK_FORM . "div[2]/div[1]/label" ) );
76 // 'Wiki language' dropdown available
77 $this->assertTrue( $this->isElementPresent( "ContLang" ) );
80 public function testWelcometoMediaWikiUI() {
81 parent::navigateWelcometoMediaWikiPage();
83 // Verify 'Welcome to MediaWiki!' heading
84 $this->assertEquals( "Welcome to MediaWiki!",
85 $this->getText( LINK_DIV . "h2" ) );
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" ) );
92 public function testConnectToDatabaseUI() {
93 parent::navigateConnetToDatabasePage();
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]" ) );
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 " ) );
104 // 'Database host' label available
105 $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" ) );
107 // 'Database host' text box default to 'localhost'
108 $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" ) );
110 // 'Identify this wiki' section available
111 $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) );
113 // 'Identify this wiki' label available
114 $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) );
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" ) );
120 // Verify 'Database name:' text box is default to 'my_wiki'
121 $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" ) );
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" ) );
127 // 'User account for installation' section available
128 $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) );
130 // 'User account for installation' label available
131 $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) );
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" ) );
137 // 'Database username' text box defaults to 'root'
138 $this->assertEquals( "root", $this->getValue( "mysql__InstallUser" ) );
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" ) );
145 public function testDatabaseSettingsUI() {
146 $databaseName = DB_NAME_PREFIX . "_db_settings_UI";
147 parent::navigateDatabaseSettingsPage( $databaseName );
149 // 'Database settings' text available.
150 $this->assertEquals( "Database settings", $this->getText( LINK_DIV . "h2" ) );
152 // 'Database account for web access' section available
153 $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) );
155 // 'Database account for web access' label available
156 $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM . "fieldset/legend" ) );
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" ) );
161 // 'Use the same account as for installation' check box is selected by default
162 $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ) );
164 // 'Use the same account as for installation' check box deselected
165 $this->click( "mysql__SameAccount" );
167 // verify 'Use the same account as for installation' check box is not selected
168 $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" ) );
170 // 'Database username' label available
171 $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" ) );
173 // 'Database username' text box is default to the 'wikiuser'
174 $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" ) );
176 // 'Database password' label available
177 $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" ) );
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" ) );
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" ) );
185 // 'Create the account if it does not already exist' check box selected
186 $this->click( "mysql__CreateDBAccount" );
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" ) );
193 // 'Storage engine' label available
194 $this->assertEquals( "Storage engine:",
195 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
197 // 'InnoDB' label available
198 $this->assertEquals( "InnoDB",
199 $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[1]/label" ) );
201 // 'InnoDB' radio button available
202 $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" ) );
204 // 'MyISAM' label available
205 $this->assertEquals( "MyISAM", $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[2]/label" ) );
207 // 'MyISAM' radio button available
208 $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_MyISAM" ) );
210 // 'Database character set' label available
211 $this->assertEquals( "Database character set:",
212 $this->getText( LINK_FORM . "div[3]/div[1]/label" ) );
214 // 'Binary' radio button available
215 $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" ) );
217 // 'Binary' radio button available
218 $this->assertEquals( "Binary", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[1]/label" ) );
220 // 'UTF-8' radio button available
221 $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" ) );
223 // 'UTF-8' label available
224 $this->assertEquals( "UTF-8", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[2]/label" ) );
226 // 'Binary' radio button is selected
227 $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" ) );
230 public function testNamePageUI() {
231 $databaseName = DB_NAME_PREFIX . "_name_UI";
232 parent::navigateNamePage( $databaseName );
234 // 'Name of wiki' text box available
235 $this->assertEquals( "Name of wiki:",
236 $this->getText( LINK_FORM . "div[1]/div[1]/label" ) );
238 $this->assertTrue( $this->isElementPresent( "config_wgSitename" ) );
240 // 'Project namespace' label available
241 $this->assertEquals( "Project namespace:",
242 $this->getText( LINK_FORM . "div[2]/div[1]/label" ) );
244 // 'Same as the wiki name' radio button available
245 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" ) );
247 // 'Project' radio button available
248 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" ) );
250 // 'Project' radio button available
251 $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" ) );
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" ) );
257 // 'Project' label available
258 $this->assertEquals( "Project",
259 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[2]/label" ) );
261 // 'Project' label available
262 $this->assertEquals( "Other (specify)",
263 $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[3]/label" ) );
265 // 'Same as the wiki name' radio button selected by default
266 $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" ) );
268 // 'Administrator account' section available
269 $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) );
271 // 'Administrator account' label available
272 $this->assertEquals( "Administrator account",
273 $this->getText( LINK_FORM . "fieldset/legend" ) );
275 // 'Your Name' label available
276 $this->assertEquals( "Your name:",
277 $this->getText( LINK_FORM . "fieldset/div[1]/div[1]/label" ) );
279 // 'Your Name' text box available
280 $this->assertTrue( $this->isElementPresent( "config__AdminName" ) );
282 // 'Password' label available
283 $this->assertEquals( "Password:",
284 $this->getText( LINK_FORM . "fieldset/div[2]/div[1]/label" ) );
286 // 'Password' text box available
287 $this->assertTrue( $this->isElementPresent( "config__AdminPassword" ) );
289 // 'Password again' label available
290 $this->assertEquals( "Password again:",
291 $this->getText( LINK_FORM . "fieldset/div[3]/div[1]/label" ) );
293 // 'Password again' text box available
294 $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" ) );
296 // 'Email address' label avaialble
297 $this->assertEquals( "E-mail address:",
298 $this->getText( LINK_FORM . "fieldset/div[4]/div[1]/label" ) );
300 // 'Email address' text box available
301 $this->assertTrue( $this->isElementPresent( "config__AdminEmail" ) );
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" ) );
307 // 'Ask me more questions.' radio button available
308 $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" ) );
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" ) );
314 // 'I'm bored already, just install the wiki' radio button is avaiable
315 $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" ) );
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" ) );
321 // 'Ask me more questions.' radio button is default selected
322 $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" ) );
325 public function testOptionPageUI() {
326 $databaseName = DB_NAME_PREFIX . "_options_UI";
327 parent::navigateOptionsPage( $databaseName );
329 // 'Options' label available
330 $this->assertEquals( "Options", $this->getText( LINK_DIV . "h2" ) );
332 // 'Return e-mail address' label available
333 $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" ) );
335 // 'Return e-mail address' text box available
336 $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" ) );
338 // Text 'apache@localhost' is default value of the 'Return e-mail address' text box
339 $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" ) );
341 // 'Logo URL' label available
342 $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM . "fieldset[2]/div[3]/div[1]/label" ) );
344 // 'Logo URL' text box available
345 $this->assertTrue( $this->isElementPresent( "config_wgLogo" ) );
347 // Correct path available in the 'Logo URL' text box
348 $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" ) );
350 // 'Enable file uploads' radio button available
351 $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" ) );
353 // 'Enable file uploads' label available
354 $this->assertEquals( "Enable file uploads",
355 $this->getText( LINK_FORM . "fieldset[2]/div[1]/label" ) );
357 // 'Enable file uploads' check box is not selected
358 $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" ) );
360 $this->click( "config_wgEnableUploads" );
362 // 'Directory for deleted files' label available
363 $this->assertEquals( "Directory for deleted files:",
364 $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" ) );
366 // 'Directory for deleted files' text box available
367 $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" ) );
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" ) );
374 public function testInstallPageUI() {
375 $databaseName = DB_NAME_PREFIX . "_install_UI";
376 parent::navigateInstallPage( $databaseName );
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]" ) );
397 public function testCompletePageUI() {
398 $databaseName = DB_NAME_PREFIX . "_complete_UI";
399 parent::navigateCompletePage( $databaseName );
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]" ) );
408 // 'Download LocalSettings.php'' link available
409 $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" ) );
411 // 'enter your wiki' link available
412 $this->assertTrue( $this->isElementPresent( "link=Folder/index.php enter your wiki" ) );
415 public function testRestartInstallation() {
416 parent::navigateConnetToDatabasePage();
417 $this->click( "link=Restart installation" );
418 $this->waitForPageToLoad( PAGE_LOAD_TIME );
420 // Restart installation' label should be available.
421 $this->assertEquals( "Restart installation", $this->getText( LINK_DIV . "h2" ) );
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" ) );
429 // 'Restart' button available
430 $this->assertTrue( $this->isElementPresent( "submit-restart" ) );
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 );
440 // 'Language' page
441 parent::mediaWikiLogoPresent();
442 parent::clickContinueButton();
444 // 'Welcome to MediaWiki' page
445 parent::mediaWikiLogoPresent();
446 parent::clickContinueButton();
448 // 'Connet to database' page
449 parent::mediaWikiLogoPresent();
450 $this->type( "mysql_wgDBname", $databaseName );
451 parent::clickContinueButton();
453 // 'Database setting' page
454 parent::mediaWikiLogoPresent();
455 parent::clickContinueButton();
457 // 'Name' page
458 parent::mediaWikiLogoPresent();
459 parent::completeNamePage();
460 parent::clickContinueButton();
462 // 'Options' page
463 parent::mediaWikiLogoPresent();
464 parent::clickContinueButton();
466 // 'Install' page
467 parent::mediaWikiLogoPresent();
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" ) );