diff options
Diffstat (limited to 'tests/selenium/installer')
19 files changed, 2322 insertions, 0 deletions
diff --git a/tests/selenium/installer/MediaWikiButtonsAvailabilityTestCase.php b/tests/selenium/installer/MediaWikiButtonsAvailabilityTestCase.php new file mode 100644 index 00000000..3557f516 --- /dev/null +++ b/tests/selenium/installer/MediaWikiButtonsAvailabilityTestCase.php @@ -0,0 +1,102 @@ +<?php + +/** + * MediaWikiButtonsAvailabilityTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 30 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name :'Back' and 'Continue' button availability + * Version : MediaWiki 1.18alpha +*/ + + +class MediaWikiButtonsAvailabilityTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + + // Verify only 'Continue' button available on 'Language' page + public function testOnlyContinueButtonAvailability() { + + parent::navigateLanguagePage(); + + // Verify only 'Continue' button avaialble + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + + // 'Back' button is not avaialble + $this->assertElementNotPresent( "submit-back" ); + } + + + // Verify 'Continue' and 'Back' buttons availability + public function testBothButtonsAvailability() { + + // Verify buttons availability on 'Welcome to MediaWiki' page + parent::navigateWelcometoMediaWikiPage(); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + parent::restartInstallation(); + + // Verify buttons availability on 'Connect to Database' page + parent::navigateConnetToDatabasePage(); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + parent::restartInstallation(); + + // Verify buttons availability on 'Database settings' page + $databaseName = DB_NAME_PREFIX."_db_settings"; + parent::navigateDatabaseSettingsPage( $databaseName ); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + parent::restartInstallation(); + + // Verify buttons availability on 'Name' page + $databaseName = DB_NAME_PREFIX."_name"; + parent::navigateNamePage( $databaseName ); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + parent::restartInstallation(); + + // Verify buttons availability on 'Options' page + $databaseName = DB_NAME_PREFIX."_options"; + parent::navigateOptionsPage( $databaseName ); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + parent::restartInstallation(); + + // Verify buttons availability on 'Install' page + $databaseName = DB_NAME_PREFIX."_install"; + parent::navigateInstallPage($databaseName); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + $this->assertTrue( $this->isElementPresent( "submit-continue" )); + } +}
\ No newline at end of file diff --git a/tests/selenium/installer/MediaWikiDifferentDatabaseAccountTestCase.php b/tests/selenium/installer/MediaWikiDifferentDatabaseAccountTestCase.php new file mode 100644 index 00000000..4afcdc0e --- /dev/null +++ b/tests/selenium/installer/MediaWikiDifferentDatabaseAccountTestCase.php @@ -0,0 +1,82 @@ +<?php + +/** + * MediaWikiDifferentDatabaseAccountTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationCommonFunction.php' ); + +/* + * Test Case ID : 04 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install MediaWiki with different Database accounts for web access. + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiDifferentDatabaseAccountTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + + // Install Mediawiki using 'MySQL' database type. + public function testDifferentDatabaseAccount() { + + $databaseName = DB_NAME_PREFIX."_dif_accounts"; + + // Navigate to the 'Database settings' page + parent::navigateDatabaseSettingsPage( $databaseName ); + + // Click on the 'Use the same account as for installation' check box + $this->click( "mysql__SameAccount" ); + + // Change the 'Database username' + $this->type( "mysql_wgDBuser", DB_WEB_USER ); + + // Enter 'Database password:' + $this->type( "mysql_wgDBpassword", DB_WEB_USER_PASSWORD ); + + // Select 'Create the account if it does not already exist' check box + $this->click( "mysql__CreateDBAccount" ); + parent::clickContinueButton(); + + // 'Name' page + parent::completeNamePage(); + + // 'Options' page + parent::clickContinueButton(); + + // 'Install' page + $this->assertEquals("Creating database user... done", + $this->getText( LINK_FORM."ul/li[3]")); + parent::clickContinueButton(); + + // 'Complete' page + parent::completePageSuccessfull(); + $this->chooseCancelOnNextConfirmation(); + } +} diff --git a/tests/selenium/installer/MediaWikiDifferntDatabasePrefixTestCase.php b/tests/selenium/installer/MediaWikiDifferntDatabasePrefixTestCase.php new file mode 100644 index 00000000..b6a0fc09 --- /dev/null +++ b/tests/selenium/installer/MediaWikiDifferntDatabasePrefixTestCase.php @@ -0,0 +1,95 @@ +<?php + +/** + * MediaWikiDifferntDatabasePrefixTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationCommonFunction.php' ); + +/* + * Test Case ID : 02 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install MediaWiki with the same database and the different + * database prefixes(Share one database between multiple wikis). + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiDifferntDatabasePrefixTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Install Mediawiki using 'MySQL' database type. + public function testDifferentDatabasePrefix() { + + $databaseName = DB_NAME_PREFIX."_db_prefix"; + parent::navigateInstallPage( $databaseName ); + + // To 'Options' page + parent::clickBackButton(); + + // To 'Name' page + parent::clickBackButton(); + + // To 'Database settings' page + parent::clickBackButton(); + + // To 'Connect to database' page + parent::clickBackButton(); + + // From 'Connect to database' page without database prefix + parent::clickContinueButton(); + + // Verify upgrade existing message + $this->assertEquals( "Upgrade existing installation", + $this->getText( LINK_DIV."h2" )); + + // To 'Connect to database' page + parent::clickBackButton(); + + // Input the database prefix + $this->type( "mysql_wgDBprefix", DATABASE_PREFIX ); + + // From 'Connect to database' page with database prefix + parent::clickContinueButton(); + + // To 'Complete' page + parent::clickContinueButton(); + parent::completeNamePage(); + parent::clickContinueButton(); + + // Verify already installed warning message + $this->assertEquals( "Install", + $this->getText( LINK_DIV."h2" )); + $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_FORM."div[1]" )); + + parent::clickContinueButton(); + parent::completePageSuccessfull(); + $this->chooseCancelOnNextConfirmation(); + parent::restartInstallation(); + } +} diff --git a/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php b/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php new file mode 100644 index 00000000..3642a8ef --- /dev/null +++ b/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php @@ -0,0 +1,136 @@ +<?php + +/** + * MediaWikiErrorsConnectToDatabasePageTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationCommonFunction.php' ); + +/* + * Test Case ID : 09 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Invalid/ blank values for fields in 'Connect to database' page. + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiErrorsConnectToDatabasePageTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Verify warning messages for the 'Connet to database' page + public function testErrorsConnectToDatabasePage() { + + parent::navigateConnetToDatabasePage(); + + // Verify warning mesage for invalid database host + $this->type( "mysql_wgDBserver", INVALID_DB_HOST ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (".INVALID_DB_HOST.").", + $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); + // Verify warning message for the blank database host + $this->type( "mysql_wgDBserver", "" ); + parent::clickContinueButton(); + $this->assertEquals( "MySQL 4.0.14 or later is required, you have .", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + // Valid Database Host + $this->type( "mysql_wgDBserver", VALID_DB_HOST ); + + // Verify warning message for the invalid database name + $this->type( "mysql_wgDBname", INVALID_DB_NAME ); + parent::clickContinueButton(); + $this->assertEquals( "Invalid database name \"".INVALID_DB_NAME."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", + $this->getText( LINK_DIV."div[2]/div[2]/p" )); + + // Verify warning message for the blank database name + $this->type( "mysql_wgDBname", ""); + parent::clickContinueButton(); + $this->assertEquals( "You must enter a value for \"Database name\"", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + // valid Database name + $this->type( "mysql_wgDBname", VALID_DB_NAME); + + // Verify warning message for the invalid databaase prefix + $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX ); + parent::clickContinueButton(); + $this->assertEquals( "Invalid database prefix \"".INVALID_DB_PREFIX."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + // Valid Database prefix + $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX ); + + // Verify warning message for the invalid database user name + $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: NO) (localhost).", + $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV."div[2]/div[2]/p[2]")); + + // Verify warning message for the blank database user name + $this->type( "mysql__InstallUser", "" ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).", + $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); + + // Valid Database username + $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); + + // Verify warning message for the invalid password + $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); + parent::clickContinueButton(); + + $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).", + $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); + + // Verify warning message for the invalid username and password + $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); + $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: YES) (localhost).", + $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); + + // Valid username and valid password + $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); + $this->type( "mysql__InstallPassword", "" ); + parent::clickContinueButton(); + + // successfully completes the 'Connect to database' page + $this->assertEquals( "Database settings", + $this->getText( LINK_DIV."h2" )); + } +} diff --git a/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php b/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php new file mode 100644 index 00000000..d70dcc42 --- /dev/null +++ b/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php @@ -0,0 +1,132 @@ +<?php + +/** + * MediaWikiErrorsNamepageTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +/* + * Test Case ID : 10 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Invalid/ blank values for fields in 'Name' page. + * Version : MediaWiki 1.18alpha +*/ + +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationCommonFunction.php' ); + +class MediaWikiErrorsNamepageTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Verify warning message for the 'Name' page + public function testErrorsNamePage() { + + $databaseName = DB_NAME_PREFIX."_error_name"; + + parent::navigateNamePage( $databaseName ); + + // Verify warning message for all blank fields + parent::clickContinueButton(); + $this->assertEquals( "Enter a site name.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + $this->assertEquals( "Enter an administrator username.", + $this->getText( LINK_DIV."div[3]/div[2]" )); + $this->assertEquals( "Enter a password for the administrator account.", + $this->getText( LINK_DIV."div[4]/div[2]" )); + + // Verify warning message for the blank 'Site name' + $this->type( "config__AdminName", VALID_YOUR_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", VALID_PASSWORD_AGAIN ); + parent::clickContinueButton(); + $this->assertEquals( "Enter a site name.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + // Input valid 'Site name' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + + + // Verify warning message for the invalid "Project namespace' + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace", INVALID_NAMESPACE ); + parent::clickContinueButton(); + $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + + // Verify warning message for the blank 'Project namespace' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace" , "" ); + parent::clickContinueButton(); + $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + + // Valid 'Project namespace' + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace", VALID_NAMESPACE ); + parent::clickContinueButton(); + + + // Valid 'Site name' + $this->click( "config__NamespaceType_site-name" ); + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + + + // Verify warning message for blank 'Your name' + $this->type( "config__AdminName", " " ); + parent::clickContinueButton(); + $this->assertEquals( "Enter an administrator username.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + // Verify warning message for blank 'Password' + $this->type( "config__AdminName", VALID_YOUR_NAME ); + $this->type( "config__AdminPassword", " " ); + parent::clickContinueButton(); + $this->assertEquals( "Enter a password for the administrator account.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + + // Verify warning message for the blank 'Password again' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", " " ); + parent::clickContinueButton(); + $this->assertEquals( "The two passwords you entered do not match.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + + + // Verify warning message for the different'Password' and 'Password again' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", INVALID_PASSWORD_AGAIN ); + parent::clickContinueButton(); + $this->assertEquals( "The two passwords you entered do not match.", + $this->getText( LINK_DIV."div[2]/div[2]" )); + } +} diff --git a/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php b/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php new file mode 100644 index 00000000..355a2857 --- /dev/null +++ b/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php @@ -0,0 +1,140 @@ +<?php + +/** + * MediaWikiHelpFieldHintTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +/* + * Test Case ID : 29 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Help field hint availability for the fields. + * Version : MediaWiki 1.18alpha +*/ + +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationCommonFunction.php' ); + +class MediaWikiHelpFieldHintTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + + // Verify help field availability for the fields + public function testMySQLConnectToDatabaseFieldHint() { + + parent::navigateConnetToDatabasePage(); + + // Verify help field for 'Database host' + $this->click( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_HOST_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[2]" ) ); + + // Verify help field for 'Database name' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_NAME_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]" )); + + + // Verify help field for 'Database table prefix' + $this->click("//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/div/span[1]" ); + $this->assertEquals(MYSQL_DATABASE_TABLE_PREFIX_HELP, + $this->getText("//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]/p[1]" )); + + // Verify help field for 'Database username' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATBASE_USERNAME_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[2]" )); + + // Verify help field for 'Database password' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_PASSWORD_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[2]/p" )); + } + + + public function testSQLiteConnectToDatabaseFieldHint() { + + parent::navigateConnetToDatabasePage(); + $this->click( "DBType_sqlite" ); + + // Verify help field for 'SQLite data directory' + $this->click( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( SQLITE_DATA_DIRECTORY_HELP, + $this->getText( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[2]" )); + + // Verify help field for 'Database name' + $this->click( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[1]" ); + $this->assertEquals( SQLITE_DATABASE_NAME_HELP , $this->getText( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[2]/p" )); + } + + + public function testDatabaseSettingsFieldHint() { + + $databaseName = DB_NAME_PREFIX."_db_field"; + parent::navigateDatabaseSettingsPage($databaseName); + + // Verify help field for 'Search engine' + $this->click( LINK_FORM."div[2]/span[1]" ); + $this->assertEquals( SEARCH_ENGINE_HELP, + $this->getText( LINK_FORM."div[2]/span[2]" )); + + // Verify help field for 'Database character set' + $this->click( LINK_FORM."div[4]/span[1]" ); + $this->assertEquals( DATABASE_CHARACTER_SET_HELP, + $this->getText( LINK_FORM."div[4]/span[2]")); + parent::restartInstallation(); + } + + + public function testNameFieldHint() { + + $databaseName = DB_NAME_PREFIX."_name_field"; + parent::navigateNamePage( $databaseName ); + + // Verify help field for 'Name of Wiki' + $this->click( LINK_FORM."div[1]/div[1]/div/span[1]" ); + $this->assertEquals( NAME_OF_WIKI_HELP, + $this->getText( LINK_FORM."div[1]/div[1]/div/span[2]/p" )); + + // Verify help field for 'Project namespace' + $this->click( LINK_FORM."div[2]/div[1]/div/span[1]" ); + $this->assertEquals( PROJECT_NAMESPACE_HELP, + $this->getText( LINK_FORM."div[2]/div[1]/div/span[2]/p")); + + // Verify help field for 'Your Name' + $this->click( LINK_FORM."fieldset/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( USER_NAME_HELP, + $this->getText( LINK_FORM."fieldset/div[1]/div[1]/div/span[2]/p" )); + + // Verify help field for 'E mail address' + $this->click( LINK_FORM."fieldset/div[4]/div[1]/div/span[1]" ); + $this->assertEquals( EMAIL_ADDRESS_HELP, + $this->getText( LINK_FORM."fieldset/div[4]/div[1]/div/span[2]/p" )); + + parent::restartInstallation(); + } +} + diff --git a/tests/selenium/installer/MediaWikiInstallationCommonFunction.php b/tests/selenium/installer/MediaWikiInstallationCommonFunction.php new file mode 100644 index 00000000..99df8a2a --- /dev/null +++ b/tests/selenium/installer/MediaWikiInstallationCommonFunction.php @@ -0,0 +1,283 @@ +<?php +/** + * MediaWikiInstallationCommonFunction + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; +require_once ( dirname( __FILE__ ) . '/MediaWikiInstallationConfig.php' ); +require_once ( dirname(__FILE__) . '/MediaWikiInstallationMessage.php' ); +require_once ( dirname(__FILE__) . '/MediaWikiInstallationVariables.php'); + + +class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase { + + function setUp() { + $this->setBrowser( TEST_BROWSER ); + $this->setBrowserUrl("http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/"); + } + + + public function navigateInitialpage() { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/" ); + } + + + // Navigate to the 'Language' page + public function navigateLanguagePage() { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + } + + + // Navigate to the 'Welcome to MediaWiki' page + public function navigateWelcometoMediaWikiPage() { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + $this->click( "submit-continue "); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate yo 'Connect to Database' page + public function navigateConnetToDatabasePage() { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click("submit-continue"); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate to the 'Database Settings' page + public function navigateDatabaseSettingsPage( $databaseName ) { + + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click("submit-continue"); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click("submit-continue"); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type("mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate to the 'Name' page + public function navigateNamePage( $databaseName ) { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate 'Options' page + public function navigateOptionsPage( $databaseName ) { + + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate 'Install' page + public function navigateInstallPage( $databaseName ) { + + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Options page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Navigate to 'Complete' page + public function navigateCompletePage( $databaseName ) { + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Options page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Install page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->chooseCancelOnNextConfirmation(); + } + + + // Complete the Name page fields + public function completeNamePage() { + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME); + } + + + // Clicking on the 'Continue' button in any MediaWiki page + public function clickContinueButton() { + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Clicking on the 'Back' button in any MediaWiki page + public function clickBackButton() { + $this->click( "submit-back" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Restarting the installation + public function restartInstallation() { + $this->click( "link=Restart installation" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->click( "submit-restart" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + + // Verify 'MediaWiki' logo available in the initial screen + public function mediaWikiLogoPresentInitialScreen() { + $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" )); + } + + + // Verify 'MediaWiki' logo available + public function mediaWikiLogoPresent() { + $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" )); + } + + + public function completePageSuccessfull() { + $this->assertEquals( "Complete!", + $this->getText( "//div[@id='bodyContent']/div/div/h2" )); + + // 'Congratulations!' text should be available in the 'Complete!' page. + $this->assertEquals( "Congratulations!", + $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" )); + } +} diff --git a/tests/selenium/installer/MediaWikiInstallationConfig.php b/tests/selenium/installer/MediaWikiInstallationConfig.php new file mode 100644 index 00000000..d3067d69 --- /dev/null +++ b/tests/selenium/installer/MediaWikiInstallationConfig.php @@ -0,0 +1,49 @@ +<?php + +/** + * MediaWikiInstallationConfig + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +/* + * MediaWikiInstallerTestSuite.php can be run one time successfully + * with current value of the 'DB_NAME_PREFIX'. + * If you wish to run the suite more than one time, you need to change + * the value of the 'DB_NAME_PREFIX'. +*/ +define('DB_NAME_PREFIX', "database_name" ); +define('DIRECTORY_NAME', "mediawiki" ); +define( 'PORT', "8080" ); +define( 'HOST_NAME', "localhost" ); + +/* + * Use the followings to run the test suite in different browsers. + * Firefox : *firefox + * IE : *iexplore + * Google chrome : *googlechrome + * Opera : *opera +*/ +define ( 'TEST_BROWSER', "*firefox" ); diff --git a/tests/selenium/installer/MediaWikiInstallationMessage.php b/tests/selenium/installer/MediaWikiInstallationMessage.php new file mode 100644 index 00000000..a348b542 --- /dev/null +++ b/tests/selenium/installer/MediaWikiInstallationMessage.php @@ -0,0 +1,57 @@ +<?php + +/** + * MediaWikiInstallationConfig + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +// 'MySQL' database type help field hint +define( 'MYSQL_DATABASE_HOST_HELP', "If your database server is on different server, enter the host name or IP address here. \nIf you are using shared web hosting, your hosting provider should give you the correct host name in their documentation. \nIf you are installing on a Windows server and using MySQL, using \"localhost\" may not work for the server name. If it does not, try \"127.0.0.1\" for the local IP address." ); +define( 'MYSQL_DATABASE_NAME_HELP', "Choose a name that identifies your wiki. It should not contain spaces or hyphens. \nIf you are using shared web hosting, your hosting provider will either give you a specific database name to use or let you create databases via a control panel." ); +define( 'MYSQL_DATABASE_TABLE_PREFIX_HELP', "Choose a name that identifies your wiki. It should not contain spaces or hyphens."); +define( 'MYSQL_DATBASE_USERNAME_HELP', "Enter the username that will be used to connect to the database during the installation process. This is not the username of the MediaWiki account; this is the username for your database." ); +define( 'MYSQL_DATABASE_PASSWORD_HELP', "Enter the password that will be used to connect to the database during the installation process. This is not the password for the MediaWiki account; this is the password for your database." ); + + +// 'SQLite' database type help field hint +define( 'SQLITE_DATA_DIRECTORY_HELP', "SQLite stores all data in a single file. \nThe directory you provide must be writable by the webserver during installation. \nIt should not be accessible via the web, this is why we're not putting it where your PHP files are. \nThe installer will write a .htaccess file along with it, but if that fails someone can gain access to your raw database. That includes raw user data (e-mail addresses, hashed passwords) as well as deleted revisions and other restricted data on the wiki. \nConsider putting the database somewhere else altogether, for example in /var/lib/mediawiki/yourwiki." ); +define( 'SQLITE_DATABASE_NAME_HELP', "Choose a name that identifies your wiki. Do not use spaces or hyphens. This will be used for the SQLite data file name."); + + +// 'Database settings' page hel0p field hint +define( 'SEARCH_ENGINE_HELP', "InnoDB is almost always the best option, since it has good concurrency support. \nMyISAM may be faster in single-user or read-only installations. MyISAM databases tend to get corrupted more often than InnoDB databases." ); +define( 'DATABASE_CHARACTER_SET_HELP', "In binary mode, MediaWiki stores UTF-8 text to the database in binary fields. This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. \nIn UTF-8 mode, MySQL will know what character set your data is in, and can present and convert it appropriately, but it will not let you store characters above the Basic Multilingual Plane." ); + + +// 'Name' page help field hint +define( 'NAME_OF_WIKI_HELP', "This will appear in the title bar of the browser and in various other places."); +define( 'PROJECT_NAMESPACE_HELP', "Following Wikipedia's example, many wikis keep their policy pages separate from their content pages, in a \"project namespace\". All page titles in this namespace start with a certain prefix, which you can specify here. Traditionally, this prefix is derived from the name of the wiki, but it cannot contain punctuation characters such as \"#\" or \":\"." ); +define( 'USER_NAME_HELP', "Enter your preferred username here, for example \"Joe Bloggs\". This is the name you will use to log in to the wiki." ); +define( 'EMAIL_ADDRESS_HELP', "Enter an e-mail address here to allow you to receive e-mail from other users on the wiki, reset your password, and be notified of changes to pages on your watchlist." ); +define( 'SUBSCRIBE_MAILING_LIST_HELP', "This is a low-volume mailing list used for release announcements, including important security announcements. You should subscribe to it and update your MediaWiki installation when new versions come out." ); + + + diff --git a/tests/selenium/installer/MediaWikiInstallationVariables.php b/tests/selenium/installer/MediaWikiInstallationVariables.php new file mode 100644 index 00000000..bb11d022 --- /dev/null +++ b/tests/selenium/installer/MediaWikiInstallationVariables.php @@ -0,0 +1,77 @@ +<?php + +/** + * MediaWikiInstallationConfig + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +// Common variables +define('PAGE_LOAD_TIME', "80000" ); + +// Common links +define( 'LINK_DIV', "//div[@id='bodyContent']/div/div/"); +define( 'LINK_FORM', "//div[@id='bodyContent']/div/div/div[2]/form/" ); +define( 'LINK_RIGHT_FRAMEWORK', "//div[@id='bodyContent']/div/div/div[1]/ul[1]/"); + +// 'Name' page input values +define( 'NAME_OF_WIKI', "Site Name" ); +define( 'ADMIN_USER_NAME', "My Name" ); +define( 'ADMIN_PASSWORD', "12345" ); +define ( 'ADMIN_RETYPE_PASSWORD', "12345" ); +define ( 'ADMIN_EMAIL_ADDRESS', "admin@example.com" ); + + +// 'Name' page input values for warning messages +define( 'VALID_WIKI_NAME', "MyWiki" ); +define( 'VALID_YOUR_NAME', "FirstName LastName" ); +define( 'VALID_PASSWORD', "12345" ); +define( 'VALID_PASSWORD_AGAIN', "12345" ); +define( 'INVALID_PASSWORD_AGAIN', "123" ); +define( 'VALID_NAMESPACE', "Mynamespace" ); +define( 'INVALID_NAMESPACE', "##..##" ); + + +// 'Database settings' page input values +define( 'DB_WEB_USER', "different" ); +define('DB_WEB_USER_PASSWORD', "12345" ); + + +// 'Connet to database' page input values +define( 'DATABASE_PREFIX',"databaseprefix" ); + + +// 'Connet to database' page input values for warning messages +define( 'VALID_DB_HOST', "localhost" ); +define( 'INVALID_DB_HOST', "local" ); +define( 'INVALID_DB_NAME', "my-wiki" ); +define( 'VALID_DB_NAME', "my_wiki1"); +define( 'INVALID_DB_PREFIX', "database prefix" ); +define( 'VALID_DB_PREFIX', "database_prefix"); +define( 'INVALID_DB_USER_NAME', "roots" ); +define( 'VALID_DB_USER_NAME', "root"); +define( 'INVALID_DB_PASSWORD', "12345" ); + + diff --git a/tests/selenium/installer/MediaWikiInstallerTestSuite.php b/tests/selenium/installer/MediaWikiInstallerTestSuite.php new file mode 100644 index 00000000..386a50ea --- /dev/null +++ b/tests/selenium/installer/MediaWikiInstallerTestSuite.php @@ -0,0 +1,53 @@ +<?php + +/** + * MediaWikiInstallerTestSuite + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +require_once 'PHPUnit/Framework.php'; +require_once 'PHPUnit/Framework/TestSuite.php'; + +require_once ( dirname( __FILE__ ) . '/MediaWikiUserInterfaceTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiButtonsAvailabilityTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiHelpFieldHintTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiRightFrameworkLinksTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiRestartInstallationTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiErrorsConnectToDatabasePageTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiErrorsNamepageTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiMySQLDataBaseTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiMySQLiteDataBaseTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiUpgradeExistingDatabaseTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiDifferntDatabasePrefixTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiDifferentDatabaseAccountTestCase.php' ); +require_once ( dirname( __FILE__ ) . '/MediaWikiOnAlreadyInstalledTestCase.php' ); + + + + +$suite = new PHPUnit_Framework_TestSuite('ArrayTest'); +$result = new PHPUnit_Framework_TestResult; + +$suite->run($result); diff --git a/tests/selenium/installer/MediaWikiMySQLDataBaseTestCase.php b/tests/selenium/installer/MediaWikiMySQLDataBaseTestCase.php new file mode 100644 index 00000000..abf9ddf2 --- /dev/null +++ b/tests/selenium/installer/MediaWikiMySQLDataBaseTestCase.php @@ -0,0 +1,78 @@ +<?php + +/** + * MediaWikiOnAlreadyInstalledTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 01 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install Mediawiki using 'MySQL' database type successfully + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiMySQLDataBaseTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Verify MediaWiki installation using 'MySQL' database type + public function testMySQLDatabaseSuccess() { + + $databaseName = DB_NAME_PREFIX."_sql_db"; + + parent::navigateConnetToDatabasePage(); + + // Verify 'MySQL" is selected as the default database type + $this->assertEquals( "MySQL settings", $this->getText( "//div[@id='DB_wrapper_mysql']/h3" )); + + // Change 'Database name' + $defaultDbName = $this->getText( "mysql_wgDBname" ); + $this->type( "mysql_wgDBname", " "); + $this->type( "mysql_wgDBname", $databaseName ); + $this->assertNotEquals( $defaultDbName, $databaseName ); + + // 'Database settings' page + parent::clickContinueButton(); + + // 'Name' page + parent::clickContinueButton(); + parent::completeNamePage(); + + // 'Options page + parent::clickContinueButton(); + + // 'Install' page + parent::clickContinueButton(); + + // 'Complete' page + parent::completePageSuccessfull(); + parent::restartInstallation(); + } +} diff --git a/tests/selenium/installer/MediaWikiMySQLiteDataBaseTestCase.php b/tests/selenium/installer/MediaWikiMySQLiteDataBaseTestCase.php new file mode 100644 index 00000000..fe704a42 --- /dev/null +++ b/tests/selenium/installer/MediaWikiMySQLiteDataBaseTestCase.php @@ -0,0 +1,79 @@ +<?php + +/** + * MediaWikiMySQLiteataBaseTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 06 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install Mediawiki using 'MySQL' database type successfully + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiMySQLiteDataBaseTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Verify MediaWiki installation using 'MySQL' database type + public function testMySQLDatabaseSuccess() { + + $databaseName = DB_NAME_PREFIX."_sqlite_db"; + + parent::navigateConnetToDatabasePage(); + $this->click( "DBType_sqlite" ); + + // Select 'SQLite' database type + $this->assertEquals( "SQLite settings", $this->getText( "//div[@id='DB_wrapper_sqlite']/h3" )); + + // Change database name + $defaultDbName = $this->getText( "sqlite_wgDBname" ); + $this->type( "sqlite_wgDBname", " "); + $this->type( "sqlite_wgDBname", $databaseName ); + $this->assertNotEquals( $defaultDbName, $databaseName ); + + // 'Database settings' page + parent::clickContinueButton(); + + // 'Name' page + parent::clickContinueButton(); + parent::completeNamePage(); + + // 'Options page + parent::clickContinueButton(); + + // 'Install' page + parent::clickContinueButton(); + + // 'Complete' page + parent::completePageSuccessfull(); + parent::restartInstallation(); + } +} diff --git a/tests/selenium/installer/MediaWikiOnAlreadyInstalledTestCase.php b/tests/selenium/installer/MediaWikiOnAlreadyInstalledTestCase.php new file mode 100644 index 00000000..e8b8f9b0 --- /dev/null +++ b/tests/selenium/installer/MediaWikiOnAlreadyInstalledTestCase.php @@ -0,0 +1,71 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + + +/* + * Test Case ID : 03 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install mediawiki on a already installed Mediawiki.] + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiOnAlreadyInstalledTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Install Mediawiki using 'MySQL' database type. + public function testInstallOnAlreadyInstalled() { + + $databaseName = DB_NAME_PREFIX."_already_installed"; + parent::navigateInstallPage( $databaseName ); + + // 'Options' page + parent::clickBackButton(); + + // Install page + parent::clickContinueButton(); + + // 'Install' page should display after the 'Option' page + $this->assertEquals( "Install", $this->getText( LINK_DIV."h2" )); + + // Verify warning text displayed + $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_FORM."div[1]/div[2]" )); + + // Complete page + parent::clickContinueButton(); + parent::completePageSuccessfull(); + $this->chooseCancelOnNextConfirmation(); + parent::restartInstallation(); + } +} diff --git a/tests/selenium/installer/MediaWikiRestartInstallationTestCase.php b/tests/selenium/installer/MediaWikiRestartInstallationTestCase.php new file mode 100644 index 00000000..b0a38000 --- /dev/null +++ b/tests/selenium/installer/MediaWikiRestartInstallationTestCase.php @@ -0,0 +1,115 @@ +<?php + +/** + * MediaWikiRestartInstallationTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 11, 12 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install mediawiki on a already installed Mediawiki. + * Version : MediaWiki 1.18alpha +*/ + +class MediaWikiRestartInstallationTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Verify restarting the installation + public function testSuccessRestartInstallation() { + + $dbNameBeforeRestart = DB_NAME_PREFIX."_db_before"; + parent::navigateDatabaseSettingsPage( $dbNameBeforeRestart ); + + // Verify 'Restart installation' link available + $this->assertTrue($this->isElementPresent( "link=Restart installation" )); + + // Click 'Restart installation' + $this->click( "link=Restart installation "); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Restart Installation' page displayed + $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2")); + + // Restart warning message displayed + $this->assertTrue($this->isTextPresent( "exact:Do you want to clear all saved data that you have entered and restart the installation process?" )); + + // Click on the 'Yes, restart' button + $this->click( "submit-restart" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Navigate to the initial installation page(Language). + $this->assertEquals( "Language", $this->getText( LINK_DIV."h2" )); + + // 'Welcome to MediaWiki!' page + parent::clickContinueButton(); + + // 'Connect to database' page + parent::clickContinueButton(); + + // saved data should be deleted + $dbNameAfterRestart = $this->getValue("mysql_wgDBname"); + $this->assertNotEquals($dbNameBeforeRestart, $dbNameAfterRestart); + } + + + // Verify cancelling restart + public function testCancelRestartInstallation() { + + $dbNameBeforeRestart = DB_NAME_PREFIX."_cancel_restart"; + + parent::navigateDatabaseSettingsPage( $dbNameBeforeRestart); + // Verify 'Restart installation' link available + $this->assertTrue($this->isElementPresent( "link=Restart installation" )); + + $this->click( "link=Restart installation" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Restart Installation' page displayed + $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2" )); + + // Restart warning message displayed + $this->assertTrue( $this->isTextPresent( "Do you want to clear all saved data that you have entered and restart the installation process?")); + + // Click on the 'Back' button + parent::clickBackButton(); + + // Navigates to the previous page + $this->assertEquals( "Database settings", $this->getText( LINK_DIV."h2" )); + + // 'Connect to database' page + parent::clickBackButton(); + + // Saved data remain on the page. + $dbNameAfterRestart = $this->getValue( "mysql_wgDBname" ); + $this->assertEquals( $dbNameBeforeRestart, $dbNameAfterRestart ); + } +} diff --git a/tests/selenium/installer/MediaWikiRightFrameworkLinksTestCase.php b/tests/selenium/installer/MediaWikiRightFrameworkLinksTestCase.php new file mode 100644 index 00000000..346f24f8 --- /dev/null +++ b/tests/selenium/installer/MediaWikiRightFrameworkLinksTestCase.php @@ -0,0 +1,93 @@ +<?php + +/** + * MediaWikiRightFrameworkLinksTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 14, 15, 16, 17 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : User selects 'Read me' link. + * User selects 'Release notes' link. + * User selects 'Copying' link. + * User selects 'Upgrading' link. + * Version : MediaWiki 1.18alpha +*/ + + +class MediaWikiRightFrameworkLinksTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + public function testLinksAvailability() { + + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // Verify 'Read me' link availability + $this->assertTrue($this->isElementPresent( "link=Read me" )); + + // Verify 'Release notes' link availability + $this->assertTrue($this->isElementPresent( "link=Release notes" )); + + // Verify 'Copying' link availability + $this->assertTrue($this->isElementPresent( "link=Copying" )); + } + + public function testPageNavigation() { + + $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); + + // Navigate to the 'Read me' page + $this->click( "link=Read me" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->assertEquals( "Read me", $this->getText( LINK_DIV."h2[1]" )); + $this->assertTrue($this->isElementPresent( "submit-back" )); + parent::clickBackButton(); + + // Navigate to the 'Release notes' page + $this->click( "link=Release notes" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME); + $this->assertEquals( "Release notes", $this->getText( LINK_DIV."h2[1]" )); + $this->assertTrue( $this->isElementPresent( "submit-back" )); + parent::clickBackButton(); + + // Navigate to the 'Copying' page + $this->click( "link=Copying" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->assertEquals( "Copying", $this->getText( LINK_DIV."h2[1]" )); + $this->assertTrue($this->isElementPresent( "submit-back" )); + parent::clickBackButton(); + + // Navigate to the 'Upgrading' page + $this->click( "link=Upgrading" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->assertEquals( "Upgrading", $this->getText( LINK_DIV."h2[1]" )); + } +} diff --git a/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php b/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php new file mode 100644 index 00000000..0ab5e659 --- /dev/null +++ b/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php @@ -0,0 +1,117 @@ +<?php + +/** + * MediaWikiUpgradeExistingDatabaseTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 05 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : Install Mediawiki by updating the existing database. + * Version : MediaWiki 1.18alpha +*/ + + +class MediaWikiUpgradeExistingDatabaseTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + // Install Mediawiki using 'MySQL' database type. + public function testUpgradeExistingDatabase() { + + $databaseName = DB_NAME_PREFIX."_upgrade_existing"; + parent::navigateInstallPage( $databaseName ); + + $this->open( "http://localhost:".PORT."/".DIRECTORY_NAME."/config/index.php" ); + $this->assertEquals( "Install", $this->getText( LINK_DIV."h2" )); + $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_DIV."div[2]/form/div[1]/div[2]" )); + + // 'Optionis' page + parent::clickBackButton(); + + // 'Name' page + parent::clickBackButton(); + + // 'Database settings' page + parent::clickBackButton(); + + // 'Connect to database' page + parent::clickBackButton(); + $this->type( "mysql_wgDBname", $databaseName ); + parent::clickContinueButton(); + + // 'Upgrade existing installation' page displayed next to the 'Connect to database' page. + $this->assertEquals( "Upgrade existing installation", $this->getText( LINK_DIV."h2" )); + + // Warning message displayed. + $this->assertEquals( "There are MediaWiki tables in this database. To upgrade them to MediaWiki 1.18alpha, click Continue.", + $this->getText( LINK_DIV."div[2]/form/div[1]/div[2]" )); + + parent::clickContinueButton(); + $this->assertEquals( "Upgrade existing installation", + $this->getText( LINK_DIV."h2" )); + + // 'Upgrade complete.' text display + $this->assertEquals("Upgrade complete.", + $this->getText("//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[1]")); + + $this->assertEquals("You can now Folder/index.php start using your wiki.", + $this->getText("//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[2]" )); + + $this->assertEquals( "Folder/index.php start using your wiki", + $this->getText( "link=Folder/index.php start using your wiki" )); + + $this->assertTrue($this->isElementPresent( "submit-regenerate" )); + $this->click( "submit-regenerate" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->assertEquals( "Database settings", + $this->getText( LINK_DIV."h2" )); + + // 'Database settings' page + parent::clickContinueButton(); + + // Name page + parent::completeNamePage(); + + // Options page + parent::clickContinueButton(); + + // Install page + $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_FORM."div[1]/div[2]" )); + parent::clickContinueButton(); + + // complete + parent::completePageSuccessfull(); + $this->chooseCancelOnNextConfirmation(); + parent::restartInstallation(); + } +}
\ No newline at end of file diff --git a/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php b/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php new file mode 100644 index 00000000..7be39c04 --- /dev/null +++ b/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php @@ -0,0 +1,531 @@ +<?php + +/** + * MediaWikiUserInterfaceTestCase + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com> + * http://www.calcey.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @addtogroup Maintenance + * + */ + +require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php'); + +/* + * Test Case ID : 18 - 27 (http://www.mediawiki.org/wiki/New_installer/Test_plan) + * Test Case Name : UI of MediaWiki initial/ Language/ Welcome to MediaWiki!/ Connect to database/ + * Database settings/ Name/ Options/ Install/ Complete/ Restart Inslation pages + * Version : MediaWiki 1.18alpha +*/ + + +class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction { + + function setUp() { + parent::setUp(); + } + + + public function testInitialPageUI() { + + parent::navigateInitialpage(); + + // MediaWiki logo available + $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" )); + + // 'MediaWiki 1.18alpha' text available + $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" )); + + // 'LocalSettings.php not found.' text available + $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" )); + + // 'Please set up the wiki first' text available + $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" )); + + // 'set up the wiki' link available + $this->assertTrue($this->isElementPresent( "link=set up the wiki" )); + } + + + public function testlanguagePageUI() { + + parent::navigateLanguagePage(); + + // Verify 'Language' heading + $this->assertEquals( "Language", $this->getText( LINK_DIV."h2" )); + + // 'Your language' label available + $this->assertEquals( "Your language:", + $this->getText( LINK_FORM."div[1]/div[1]/label" )); + + // 'Your language' dropdown available + $this->assertTrue( $this->isElementPresent( "UserLang" )); + + // 'Wiki language' label available + $this->assertEquals( "Wiki language:", + $this->getText( LINK_FORM."div[2]/div[1]/label" )); + + // 'Wiki language' dropdown available + $this->assertTrue($this->isElementPresent( "ContLang" )); + } + + + public function testWelcometoMediaWikiUI() { + + parent::navigateWelcometoMediaWikiPage(); + + // Verify 'Welcome to MediaWiki!' heading + $this->assertEquals( "Welcome to MediaWiki!", + $this->getText( LINK_DIV."h2" )); + + // Verify environment ok text displayed. + $this->assertEquals( "The environment has been checked.You can install MediaWiki.", + $this->getText( LINK_DIV."div[6]/span" )); + } + + + public function testConnectToDatabaseUI() { + + parent::navigateConnetToDatabasePage(); + + // 'MYSQL radio button available + $this->assertEquals( "MySQL", + $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" )); + $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[1]" )); + + // 'SQLite' radio button available + $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[2]" )); + $this->assertEquals( "SQLite", $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label ")); + + // 'Database host' label available + $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" )); + + // 'Database host' text box default to 'localhost' + $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" )); + + // 'Identify this wiki' section available + $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" )); + + // 'Identify this wiki' label available + $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" )); + + // 'Database name' lable available + $this->assertEquals( "Database name:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" )); + + // Verify 'Database name:' text box is default to 'my_wiki' + $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" )); + + // Verify 'Database table prefix:' label available + $this->assertEquals( "Database table prefix:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" )); + + // 'User account for installation' section available + $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" )); + + // 'User account for installation' label available + $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" )); + + // 'Database username' label available + $this->assertEquals( "Database username:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" )); + + // 'Database username' text box defaults to 'root' + $this->assertEquals("root", $this->getValue( "mysql__InstallUser" )); + + // 'Database password' label available + $this->assertEquals( "Database password:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" )); + } + + + + public function testDatabaseSettingsUI() { + + $databaseName = DB_NAME_PREFIX."_db_settings_UI"; + parent::navigateDatabaseSettingsPage( $databaseName ); + + // 'Database settings' text available. + $this->assertEquals( "Database settings", $this->getText( LINK_DIV."h2" )); + + // 'Database account for web access' section available + $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" )); + + // 'Database account for web access' label available + $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM."fieldset/legend" )); + + // 'Use the same account as for installation' check box available + $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM."fieldset/div[1]/label" )); + + // 'Use the same account as for installation' check box is selected by default + $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" )); + + // 'Use the same account as for installation' check box deselected + $this->click( "mysql__SameAccount" ); + + // verify 'Use the same account as for installation' check box is not selected + $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" )); + + // 'Database username' label available + $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" )); + + // 'Database username' text box is default to the 'wikiuser' + $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" )); + + // 'Database password' label available + $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" )); + + // 'Create the account if it does not already exist' label available + $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" )); + + // 'Create the account if it does not already exist' check box is not selected by default + $this->assertEquals( "off" , $this->getValue( "mysql__CreateDBAccount" )); + + // 'Create the account if it does not already exist' check box selected + $this->click( "mysql__CreateDBAccount" ); + + // Verify 'Create the account if it does not already exist' check box is selected + $this->assertEquals( "on" , $this->getValue( "mysql__CreateDBAccount" )); + $this->click( "mysql__SameAccount" ); + $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" )); + + // 'Storage engine' label available + $this->assertEquals( "Storage engine:", + $this->getText( LINK_FORM."div[1]/div[1]/label")); + + // 'InnoDB' label available + $this->assertEquals( "InnoDB", + $this->getText( LINK_FORM."div[1]/div[2]/ul/li[1]/label" )); + + // 'InnoDB' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" )); + + // 'MyISAM' label available + $this->assertEquals( "MyISAM", $this->getText( LINK_FORM."div[1]/div[2]/ul/li[2]/label" )); + + // 'MyISAM' radio button available + $this->assertTrue($this->isElementPresent( "mysql__MysqlEngine_MyISAM" )); + + // 'Database character set' label available + $this->assertEquals( "Database character set:", + $this->getText( LINK_FORM."div[3]/div[1]/label" )); + + // 'Binary' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" )); + + // 'Binary' radio button available + $this->assertEquals( "Binary", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[1]/label" )); + + // 'UTF-8' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" )); + + // 'UTF-8' label available + $this->assertEquals( "UTF-8", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[2]/label" )); + + // 'Binary' radio button is selected + $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" )); + } + + + + public function testNamePageUI() { + + $databaseName = DB_NAME_PREFIX."_name_UI"; + parent::navigateNamePage($databaseName); + + // 'Name of wiki' text box available + $this->assertEquals( "Name of wiki:", + $this->getText( LINK_FORM."div[1]/div[1]/label" )); + + $this->assertTrue( $this->isElementPresent( "config_wgSitename" )); + + // 'Project namespace' label available + $this->assertEquals( "Project namespace:", + $this->getText( LINK_FORM."div[2]/div[1]/label" )); + + // 'Same as the wiki name' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" )); + + // 'Project' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" )); + + // 'Project' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" )); + + // 'Same as the wiki name' label available + $this->assertEquals( "Same as the wiki name:", + $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" )); + + // 'Project' label available + $this->assertEquals("Project", + $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label" )); + + // 'Project' label available + $this->assertEquals( "Other (specify)", + $this->getText( LINK_FORM."div[2]/div[2]/ul/li[3]/label" )); + + // 'Same as the wiki name' radio button selected by default + $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" )); + + // 'Administrator account' section available + $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" )); + + // 'Administrator account' label available + $this->assertEquals( "Administrator account", + $this->getText( LINK_FORM."fieldset/legend" )); + + // 'Your Name' label available + $this->assertEquals( "Your name:", + $this->getText( LINK_FORM."fieldset/div[1]/div[1]/label" )); + + // 'Your Name' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminName" )); + + // 'Password' label available + $this->assertEquals( "Password:", + $this->getText( LINK_FORM."fieldset/div[2]/div[1]/label" )); + + // 'Password' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminPassword" )); + + // 'Password again' label available + $this->assertEquals( "Password again:", + $this->getText( LINK_FORM."fieldset/div[3]/div[1]/label" )); + + // 'Password again' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" )); + + // 'Email address' label avaialble + $this->assertEquals( "E-mail address:", + $this->getText( LINK_FORM."fieldset/div[4]/div[1]/label" )); + + // 'Email address' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminEmail" )); + + // Message displayed + $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.", + $this->getText( LINK_FORM."/div[4]/div[2]/p" )); + + // 'Ask me more questions.' radio button available + $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" )); + + // 'Ask me more questions.' label available + $this->assertEquals( "Ask me more questions.", + $this->getText( LINK_FORM."div[5]/div[2]/ul/li[1]/label" )); + + // 'I'm bored already, just install the wiki' radio button is avaiable + $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" )); + + // 'I'm bored already, just install the wiki' label available + $this->assertEquals( "I'm bored already, just install the wiki.", + $this->getText( LINK_FORM."div[5]/div[2]/ul/li[2]/label" )); + + // 'Ask me more questions.' radio button is default selected + $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" )); + } + + + + public function testOptionPageUI() { + + $databaseName = DB_NAME_PREFIX."_options_UI"; + parent::navigateOptionsPage($databaseName); + + // 'Options' label available + $this->assertEquals( "Options", $this->getText( LINK_DIV."h2")); + + // 'Return e-mail address' label available + $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" )); + + // 'Return e-mail address' text box available + $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" )); + + // Text 'apache@localhost' is default value of the 'Return e-mail address' text box + $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" )); + + // 'Logo URL' label available + $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM."fieldset[2]/div[3]/div[1]/label" )); + + // 'Logo URL' text box available + $this->assertTrue( $this->isElementPresent( "config_wgLogo" )); + + // Correct path available in the 'Logo URL' text box + $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" )); + + // 'Enable file uploads' radio button available + $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" )); + + // 'Enable file uploads' label available + $this->assertEquals( "Enable file uploads", + $this->getText( LINK_FORM."fieldset[2]/div[1]/label" )); + + // 'Enable file uploads' check box is not selected + $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" )); + + $this->click( "config_wgEnableUploads" ); + + // 'Directory for deleted files' label available + $this->assertEquals( "Directory for deleted files:", + $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" )); + + // 'Directory for deleted files' text box available + $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" )); + + // Correct path available in the 'Directory for deleted files' text box + $this->assertEquals( "C:\\wamp\\www\\".DIRECTORY_NAME."/images/deleted", + $this->getValue( "config_wgDeletedDirectory" )); + } + + + + public function testInstallPageUI() { + + $databaseName = DB_NAME_PREFIX."_install_UI"; + parent::navigateInstallPage( $databaseName ); + + // Verify installation done messages display + $this->assertEquals( "Setting up database... done", + $this->getText( LINK_FORM."ul/li[1]" )); + $this->assertEquals( "Creating tables... done", + $this->getText( LINK_FORM."ul/li[2]" )); + $this->assertEquals( "Creating database user... done", + $this->getText( LINK_FORM."ul/li[3]" )); + $this->assertEquals( "Populating default interwiki table... done", + $this->getText( LINK_FORM."ul/li[4]" )); + $this->assertEquals( "Generating secret key... done", + $this->getText( LINK_FORM."ul/li[5]" )); + $this->assertEquals( "Generating default upgrade key... done", + $this->getText( LINK_FORM."ul/li[6]" )); + $this->assertEquals( "Creating administrator user account... done", + $this->getText( LINK_FORM."ul/li[7]" )); + $this->assertEquals( "Creating main page with default content... done", + $this->getText( LINK_FORM."ul/li[8]" )); + } + + + + public function testCompletePageUI() { + + $databaseName = DB_NAME_PREFIX."_complete_UI"; + parent::navigateCompletePage( $databaseName ); + + // 'Congratulations!' text display + $this->assertEquals("Congratulations!", + $this->getText( LINK_FORM."div[1]/div[2]/p[1]/b")); + // 'LocalSettings.php' generated message display + $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.", + $this->getText( LINK_FORM."div[1]/div[2]/p[2]" )); + + // 'Download LocalSettings.php'' link available + $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" )); + + // 'enter your wiki' link available + $this->assertTrue($this->isElementPresent("link=Folder/index.php enter your wiki")); + } + + + + public function testRestartInstallation() { + + parent::navigateConnetToDatabasePage(); + $this->click( "link=Restart installation" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Restart installation' label should be available. + $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2" )); + + //'Do you want to clear all saved data that you have entered and restart the installation process?' label available + $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?", + $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" )); + // 'Back' button available + $this->assertTrue($this->isElementPresent( "submit-back" )); + + // 'Restart' button available + $this->assertTrue($this->isElementPresent( "submit-restart" )); + } + + + + public function testMediaWikiLogoAvailability() { + + $databaseName = DB_NAME_PREFIX."_mediawiki_logo"; + parent::navigateInitialpage(); + parent::mediaWikiLogoPresentInitialScreen(); + $this->click( "link=set up the wiki" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Language' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Welcome to MediaWiki' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Connet to database' page + parent::mediaWikiLogoPresent(); + $this->type("mysql_wgDBname", $databaseName ); + parent::clickContinueButton(); + + // 'Database setting' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Name' page + parent::mediaWikiLogoPresent(); + parent::completeNamePage(); + parent::clickContinueButton(); + + // 'Options' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Install' page + parent::mediaWikiLogoPresent(); + } + + + public function testRightFramework() { + + parent::navigateLanguagePage(); + // Verfy right framework texts display + $this->assertEquals( "Language", + $this->getText( LINK_RIGHT_FRAMEWORK."li[1]" )); + $this->assertEquals( "Existing wiki", + $this->getText( LINK_RIGHT_FRAMEWORK."li[2]" )); + $this->assertEquals( "Welcome to MediaWiki!", + $this->getText( LINK_RIGHT_FRAMEWORK."li[3]" )); + $this->assertEquals( "Connect to database", + $this->getText( LINK_RIGHT_FRAMEWORK."li[4]" )); + $this->assertEquals( "Upgrade existing installation", + $this->getText( LINK_RIGHT_FRAMEWORK."li[5]" )); + $this->assertEquals( "Database settings", + $this->getText( LINK_RIGHT_FRAMEWORK."li[6]" )); + $this->assertEquals( "Name", + $this->getText( LINK_RIGHT_FRAMEWORK."li[7]" )); + $this->assertEquals( "Options", + $this->getText( LINK_RIGHT_FRAMEWORK."li[8]" )); + $this->assertEquals( "Install", + $this->getText( LINK_RIGHT_FRAMEWORK."li[9]" )); + $this->assertEquals( "Complete!", + $this->getText( LINK_RIGHT_FRAMEWORK."li[10]/span" )); + } +} diff --git a/tests/selenium/installer/README.txt b/tests/selenium/installer/README.txt new file mode 100644 index 00000000..83d1a346 --- /dev/null +++ b/tests/selenium/installer/README.txt @@ -0,0 +1,32 @@ +== Details== + +Automated Selenium test scripts written for MediaWiki Installer is available at svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/tests/selenium/installer. +Detailed test cases available at http://www.mediawiki.org/wiki/New_installer/Test_plan. + +Version : MediaWiki 1.18alpha +Date : 27/12/2010 + +== Running tests == + +Test cases can be run independently or can run all the test cases using MediaWikiInstallerTestSuite.php within PHPUnit/Selenium. + + +== Dependencies == + +MediaWikiInstallationConfig.php + +Value of the 'DB_NAME_PREFIX' should be replace with the database name prefix. Several DB instances will get created to cover different installation scenarios starting with the above prefix. +You need to change the value of the 'DB_NAME_PREFIX' in MediaWikiInstallationConfig everytime you planned to +run the tests. +'DIRECTORY_NAME', 'PORT' and the 'HOST_NAME' should be replaced with your local values. +You may specify the test browser you wish to run the test using 'TEST_BROWSER'. Default browser is Firefox. + +Note : MediaWikiInstallerTestSuite.php has no dependency on 'Selenium' test framework. + + +== Known problems == + +If you run the MediaWikiInstallerTestSuite.php twice without changing the name of the database, the second run should be falied. +(Please read the more information on how to change the database name which is avaialable under 'Dependencies' section) + + |