MediaWiki  REL1_19
MediaWikiUserInterfaceTestCase.php
Go to the documentation of this file.
00001 <?php
00002 
00030 require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
00031 
00040 class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction {
00041     
00042     function setUp() {
00043         parent::setUp();
00044     }
00045     
00046     
00047     public function testInitialPageUI() {
00048         
00049         parent::navigateInitialpage();
00050         
00051         // MediaWiki logo available
00052         $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ));
00053         
00054         // 'MediaWiki 1.18alpha' text available
00055         $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" ));
00056         
00057         // 'LocalSettings.php not found.' text available
00058         $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" ));
00059         
00060         // 'Please set up the wiki first' text available
00061         $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" ));
00062         
00063         // 'set up the wiki' link available
00064         $this->assertTrue($this->isElementPresent( "link=set up the wiki" ));
00065     }
00066     
00067     
00068     public function testlanguagePageUI() {
00069         
00070         parent::navigateLanguagePage();
00071         
00072         // Verify 'Language' heading
00073         $this->assertEquals( "Language", $this->getText( LINK_DIV."h2" ));
00074         
00075         // 'Your language' label available
00076         $this->assertEquals( "Your language:",
00077                 $this->getText( LINK_FORM."div[1]/div[1]/label" ));
00078         
00079         // 'Your language' dropdown available
00080         $this->assertTrue( $this->isElementPresent( "UserLang" ));
00081         
00082         // 'Wiki language' label available
00083         $this->assertEquals( "Wiki language:",
00084                 $this->getText( LINK_FORM."div[2]/div[1]/label" ));
00085         
00086         // 'Wiki language' dropdown available
00087         $this->assertTrue($this->isElementPresent( "ContLang" ));
00088     }
00089     
00090     
00091     public function testWelcometoMediaWikiUI() {
00092         
00093         parent::navigateWelcometoMediaWikiPage();
00094         
00095         // Verify 'Welcome to MediaWiki!' heading
00096         $this->assertEquals( "Welcome to MediaWiki!",
00097                 $this->getText( LINK_DIV."h2" ));
00098         
00099         // Verify environment ok text displayed.
00100         $this->assertEquals( "The environment has been checked.You can install MediaWiki.",
00101                 $this->getText( LINK_DIV."div[6]/span" ));
00102     }
00103     
00104     
00105     public function testConnectToDatabaseUI() {
00106         
00107         parent::navigateConnetToDatabasePage();
00108         
00109         //  'MYSQL radio button available
00110         $this->assertEquals( "MySQL",
00111                 $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" ));
00112         $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[1]" ));
00113         
00114         // 'SQLite' radio button available
00115         $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[2]" ));
00116         $this->assertEquals( "SQLite", $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label "));
00117         
00118         // 'Database host' label available
00119         $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" ));
00120         
00121         // 'Database host' text box default to 'localhost'
00122         $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" ));
00123         
00124         // 'Identify this wiki' section available
00125         $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ));
00126         
00127         // 'Identify this wiki' label available
00128         $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ));
00129         
00130         // 'Database name' lable available
00131         $this->assertEquals( "Database name:",
00132                 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" ));
00133         
00134         // Verify 'Database name:' text box is default to 'my_wiki'
00135         $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" ));
00136         
00137         // Verify 'Database table prefix:' label available
00138         $this->assertEquals( "Database table prefix:",
00139                 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" ));
00140         
00141         // 'User account for installation' section available
00142         $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ));
00143         
00144         // 'User account for installation' label available
00145         $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ));
00146         
00147         // 'Database username' label available
00148         $this->assertEquals( "Database username:",
00149                 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" ));
00150         
00151         // 'Database username' text box defaults to 'root'
00152         $this->assertEquals("root", $this->getValue( "mysql__InstallUser" ));
00153         
00154         // 'Database password' label available
00155         $this->assertEquals( "Database password:",
00156                 $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" ));
00157     }
00158     
00159     
00160     
00161     public function testDatabaseSettingsUI() {
00162         
00163         $databaseName = DB_NAME_PREFIX."_db_settings_UI";
00164         parent::navigateDatabaseSettingsPage( $databaseName );
00165         
00166         // 'Database settings' text available.
00167         $this->assertEquals( "Database settings", $this->getText( LINK_DIV."h2" ));
00168         
00169         // 'Database account for web access' section available
00170         $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" ));
00171         
00172         // 'Database account for web access' label available
00173         $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM."fieldset/legend" ));
00174         
00175         // 'Use the same account as for installation' check box available
00176         $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM."fieldset/div[1]/label" ));
00177         
00178         // 'Use the same account as for installation' check box is selected by default
00179         $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ));
00180         
00181         // 'Use the same account as for installation' check box deselected
00182         $this->click( "mysql__SameAccount" );
00183         
00184         // verify 'Use the same account as for installation' check box is not selected
00185         $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" ));
00186         
00187         // 'Database username' label available
00188         $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" ));
00189         
00190         // 'Database username' text box is default to the 'wikiuser'
00191         $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" ));
00192         
00193         // 'Database password' label available
00194         $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" ));
00195         
00196         // 'Create the account if it does not already exist' label available
00197         $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" ));
00198         
00199         // 'Create the account if it does not already exist' check box is not selected by default
00200         $this->assertEquals( "off" , $this->getValue( "mysql__CreateDBAccount" ));
00201         
00202         //  'Create the account if it does not already exist' check box selected
00203         $this->click( "mysql__CreateDBAccount" );
00204         
00205         // Verify  'Create the account if it does not already exist' check box is selected
00206         $this->assertEquals( "on" , $this->getValue( "mysql__CreateDBAccount" ));
00207         $this->click( "mysql__SameAccount" );
00208         $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ));
00209         
00210         // 'Storage engine' label available
00211         $this->assertEquals( "Storage engine:",
00212                 $this->getText( LINK_FORM."div[1]/div[1]/label"));
00213         
00214         // 'InnoDB' label available
00215         $this->assertEquals( "InnoDB",
00216                 $this->getText( LINK_FORM."div[1]/div[2]/ul/li[1]/label" ));
00217         
00218         // 'InnoDB' radio button available
00219         $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" ));
00220         
00221         // 'MyISAM' label available
00222         $this->assertEquals( "MyISAM", $this->getText( LINK_FORM."div[1]/div[2]/ul/li[2]/label" ));
00223         
00224         // 'MyISAM' radio button available
00225         $this->assertTrue($this->isElementPresent( "mysql__MysqlEngine_MyISAM" ));
00226         
00227         // 'Database character set' label available
00228         $this->assertEquals( "Database character set:",
00229                 $this->getText( LINK_FORM."div[3]/div[1]/label" ));
00230         
00231         // 'Binary' radio button available
00232         $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" ));
00233         
00234         // 'Binary' radio button available
00235         $this->assertEquals( "Binary", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[1]/label" ));
00236         
00237         // 'UTF-8' radio button available
00238         $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" ));
00239         
00240         // 'UTF-8' label available
00241         $this->assertEquals( "UTF-8", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[2]/label" ));
00242         
00243         // 'Binary' radio button is selected
00244         $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" ));
00245     }
00246     
00247     
00248     
00249     public function testNamePageUI() {
00250         
00251         $databaseName = DB_NAME_PREFIX."_name_UI";
00252         parent::navigateNamePage($databaseName);
00253         
00254         // 'Name of wiki' text box available
00255         $this->assertEquals( "Name of wiki:",
00256                 $this->getText( LINK_FORM."div[1]/div[1]/label" ));
00257         
00258         $this->assertTrue( $this->isElementPresent( "config_wgSitename" ));
00259         
00260         // 'Project namespace' label available
00261         $this->assertEquals( "Project namespace:",
00262                 $this->getText( LINK_FORM."div[2]/div[1]/label" ));
00263         
00264         // 'Same as the wiki name' radio button available
00265         $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" ));
00266         
00267         // 'Project' radio button available
00268         $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" ));
00269         
00270         // 'Project' radio button available
00271         $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" ));
00272         
00273         // 'Same as the wiki name' label available
00274         $this->assertEquals( "Same as the wiki name:",
00275                 $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" ));
00276         
00277         // 'Project' label available
00278         $this->assertEquals("Project",
00279                 $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label" ));
00280         
00281         // 'Project' label available
00282         $this->assertEquals( "Other (specify)",
00283                 $this->getText( LINK_FORM."div[2]/div[2]/ul/li[3]/label" ));
00284         
00285         //  'Same as the wiki name' radio button selected by default
00286         $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" ));
00287         
00288         // 'Administrator account' section available
00289         $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" ));
00290         
00291         // 'Administrator account' label available
00292         $this->assertEquals( "Administrator account",
00293                 $this->getText( LINK_FORM."fieldset/legend" ));
00294         
00295         // 'Your Name' label available
00296         $this->assertEquals( "Your name:",
00297                 $this->getText( LINK_FORM."fieldset/div[1]/div[1]/label" ));
00298         
00299         // 'Your Name' text box available
00300         $this->assertTrue( $this->isElementPresent( "config__AdminName" ));
00301         
00302         // 'Password' label available
00303         $this->assertEquals( "Password:",
00304                 $this->getText( LINK_FORM."fieldset/div[2]/div[1]/label" ));
00305         
00306         // 'Password' text box available
00307         $this->assertTrue( $this->isElementPresent( "config__AdminPassword" ));
00308         
00309         // 'Password again' label available
00310         $this->assertEquals( "Password again:",
00311                 $this->getText( LINK_FORM."fieldset/div[3]/div[1]/label" ));
00312         
00313         // 'Password again' text box available
00314         $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" ));
00315         
00316         // 'Email address' label avaialble
00317         $this->assertEquals( "E-mail address:",
00318                 $this->getText( LINK_FORM."fieldset/div[4]/div[1]/label" ));
00319         
00320         // 'Email address' text box available
00321         $this->assertTrue( $this->isElementPresent( "config__AdminEmail" ));
00322         
00323         // Message displayed
00324         $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.",
00325                 $this->getText( LINK_FORM."/div[4]/div[2]/p" ));
00326         
00327         // 'Ask me more questions.' radio button available
00328         $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" ));
00329         
00330         // 'Ask me more questions.' label available
00331         $this->assertEquals( "Ask me more questions.",
00332                 $this->getText( LINK_FORM."div[5]/div[2]/ul/li[1]/label" ));
00333         
00334         // 'I'm bored already, just install the wiki' radio button is avaiable
00335         $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" ));
00336         
00337         // 'I'm bored already, just install the wiki' label available
00338         $this->assertEquals( "I'm bored already, just install the wiki.",
00339                 $this->getText( LINK_FORM."div[5]/div[2]/ul/li[2]/label" ));
00340         
00341         //  'Ask me more questions.' radio button is default selected
00342         $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" ));
00343     }
00344     
00345     
00346     
00347     public function testOptionPageUI() {
00348         
00349         $databaseName = DB_NAME_PREFIX."_options_UI";
00350         parent::navigateOptionsPage($databaseName);
00351         
00352         // 'Options' label available
00353         $this->assertEquals( "Options", $this->getText( LINK_DIV."h2"));
00354         
00355         // 'Return e-mail address' label available
00356         $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" ));
00357         
00358         //    'Return e-mail address' text box available
00359         $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" ));
00360         
00361         // Text 'apache@localhost' is default value of the 'Return e-mail address' text box
00362         $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" ));
00363         
00364         // 'Logo URL' label available
00365         $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM."fieldset[2]/div[3]/div[1]/label" ));
00366         
00367         // 'Logo URL' text box available
00368         $this->assertTrue( $this->isElementPresent( "config_wgLogo" ));
00369         
00370         // Correct path available in the 'Logo URL' text box
00371         $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" ));
00372         
00373         // 'Enable file uploads' radio button available
00374         $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" ));
00375         
00376         // 'Enable file uploads' label available
00377         $this->assertEquals( "Enable file uploads",
00378                 $this->getText( LINK_FORM."fieldset[2]/div[1]/label" ));
00379         
00380         // 'Enable file uploads' check box is not selected
00381         $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" ));
00382         
00383         $this->click( "config_wgEnableUploads" );
00384         
00385         // 'Directory for deleted files' label available
00386         $this->assertEquals( "Directory for deleted files:",
00387                 $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" ));
00388         
00389         // 'Directory for deleted files' text box available
00390         $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" ));
00391         
00392         // Correct path available in the 'Directory for deleted files' text box
00393         $this->assertEquals( "C:\\wamp\\www\\".DIRECTORY_NAME."/images/deleted",
00394                 $this->getValue( "config_wgDeletedDirectory" ));
00395     }
00396     
00397     
00398     
00399     public function testInstallPageUI() {
00400         
00401         $databaseName = DB_NAME_PREFIX."_install_UI";
00402         parent::navigateInstallPage( $databaseName );
00403         
00404         // Verify installation done messages display
00405         $this->assertEquals( "Setting up database... done",
00406                 $this->getText( LINK_FORM."ul/li[1]" ));
00407         $this->assertEquals( "Creating tables... done",
00408                 $this->getText( LINK_FORM."ul/li[2]" ));
00409         $this->assertEquals( "Creating database user... done",
00410                 $this->getText( LINK_FORM."ul/li[3]" ));
00411         $this->assertEquals( "Populating default interwiki table... done",
00412                 $this->getText( LINK_FORM."ul/li[4]" ));
00413         $this->assertEquals( "Generating secret key... done",
00414                 $this->getText( LINK_FORM."ul/li[5]" ));
00415         $this->assertEquals( "Generating default upgrade key... done",
00416                 $this->getText( LINK_FORM."ul/li[6]" ));
00417         $this->assertEquals( "Creating administrator user account... done",
00418                 $this->getText( LINK_FORM."ul/li[7]" ));
00419         $this->assertEquals( "Creating main page with default content... done",
00420                 $this->getText( LINK_FORM."ul/li[8]" ));
00421     }
00422     
00423     
00424     
00425     public function testCompletePageUI() {
00426         
00427         $databaseName = DB_NAME_PREFIX."_complete_UI";
00428         parent::navigateCompletePage( $databaseName );
00429         
00430         // 'Congratulations!' text display
00431         $this->assertEquals("Congratulations!",
00432                 $this->getText( LINK_FORM."div[1]/div[2]/p[1]/b"));
00433         // 'LocalSettings.php' generated message display
00434         $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.",
00435                 $this->getText( LINK_FORM."div[1]/div[2]/p[2]" ));
00436         
00437         // 'Download LocalSettings.php'' link available
00438         $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" ));
00439         
00440         // 'enter your wiki' link available
00441         $this->assertTrue($this->isElementPresent("link=Folder/index.php enter your wiki"));
00442     }
00443     
00444     
00445     
00446     public function testRestartInstallation() {
00447         
00448         parent::navigateConnetToDatabasePage();
00449         $this->click( "link=Restart installation" );
00450         $this->waitForPageToLoad( PAGE_LOAD_TIME );
00451         
00452         // Restart installation' label should be available.
00453         $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2" ));
00454         
00455         //'Do you want to clear all saved data that you have entered and restart the installation process?' label available
00456         $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?",
00457                 $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" ));
00458         // 'Back' button available
00459         $this->assertTrue($this->isElementPresent( "submit-back" ));
00460         
00461         // 'Restart' button available
00462         $this->assertTrue($this->isElementPresent( "submit-restart" ));
00463     }
00464     
00465     
00466     
00467     public function testMediaWikiLogoAvailability() {
00468         
00469         $databaseName = DB_NAME_PREFIX."_mediawiki_logo";
00470         parent::navigateInitialpage();
00471         parent::mediaWikiLogoPresentInitialScreen();
00472         $this->click( "link=set up the wiki" );
00473         $this->waitForPageToLoad( PAGE_LOAD_TIME );
00474         
00475         // 'Language' page
00476         parent::mediaWikiLogoPresent();
00477         parent::clickContinueButton();
00478         
00479         // 'Welcome to MediaWiki' page
00480         parent::mediaWikiLogoPresent();
00481         parent::clickContinueButton();
00482         
00483         // 'Connet to database' page
00484         parent::mediaWikiLogoPresent();
00485         $this->type("mysql_wgDBname", $databaseName );
00486         parent::clickContinueButton();
00487         
00488         // 'Database setting' page
00489         parent::mediaWikiLogoPresent();
00490         parent::clickContinueButton();
00491         
00492         // 'Name' page
00493         parent::mediaWikiLogoPresent();
00494         parent::completeNamePage();
00495         parent::clickContinueButton();
00496         
00497         // 'Options' page
00498         parent::mediaWikiLogoPresent();
00499         parent::clickContinueButton();
00500         
00501         // 'Install' page
00502         parent::mediaWikiLogoPresent();
00503     }
00504     
00505     
00506     public function testRightFramework() {
00507         
00508         parent::navigateLanguagePage();
00509         // Verfy right framework texts display
00510         $this->assertEquals( "Language",
00511                 $this->getText( LINK_RIGHT_FRAMEWORK."li[1]" ));
00512         $this->assertEquals( "Existing wiki",
00513                 $this->getText( LINK_RIGHT_FRAMEWORK."li[2]" ));
00514         $this->assertEquals( "Welcome to MediaWiki!",
00515                 $this->getText( LINK_RIGHT_FRAMEWORK."li[3]" ));
00516         $this->assertEquals( "Connect to database",
00517                 $this->getText( LINK_RIGHT_FRAMEWORK."li[4]" ));
00518         $this->assertEquals( "Upgrade existing installation",
00519                 $this->getText( LINK_RIGHT_FRAMEWORK."li[5]" ));
00520         $this->assertEquals( "Database settings",
00521                 $this->getText( LINK_RIGHT_FRAMEWORK."li[6]" ));
00522         $this->assertEquals( "Name",
00523                 $this->getText( LINK_RIGHT_FRAMEWORK."li[7]" ));
00524         $this->assertEquals( "Options",
00525                 $this->getText( LINK_RIGHT_FRAMEWORK."li[8]" ));
00526         $this->assertEquals( "Install",
00527                 $this->getText( LINK_RIGHT_FRAMEWORK."li[9]" ));
00528         $this->assertEquals( "Complete!",
00529                 $this->getText( LINK_RIGHT_FRAMEWORK."li[10]/span" ));
00530     } 
00531 }