diff options
Diffstat (limited to 'maintenance/tests/selenium/suites')
21 files changed, 1452 insertions, 0 deletions
diff --git a/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php new file mode 100644 index 00000000..dd4bc005 --- /dev/null +++ b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php @@ -0,0 +1,182 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + + +class AddContentToNewPageTestCase extends SeleniumTestCase { + + + // Add bold text and verify output + public function testAddBoldText() { + + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-bold']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify bold text displayed on mediawiki preview + $this->assertTrue($this->isElementPresent( "//div[@id='wikiPreview']/p/b" )); + $this->assertTrue($this->isTextPresent( "Bold text" )); + } + + // Add italic text and verify output + public function testAddItalicText() { + + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-italic']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify italic text displayed on mediawiki preview + $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/i")); + $this->assertTrue($this->isTextPresent( "Italic text" )); + } + + // Add internal link for a new page and verify output in the preview + public function testAddInternalLinkNewPage() { + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-link']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify internal link displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $correct = strstr( $source, "Link title" ); + $this->assertEquals( $correct, true ); + + $this->click( "link=Link title" ); + $this->waitForPageToLoad( "600000" ); + + // Verify internal link open as a new page - editing mode + $source = $this->getText( "firstHeading" ); + $correct = strstr( $source, "Editing Link title" ); + $this->assertEquals( $correct, true ); + } + + // Add external link and verify output in the preview + public function testAddExternalLink() { + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-extlink']" ); + $this->type( "wpTextbox1", "[http://www.google.com Google]" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify external links displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $correct = strstr( $source, "Google" ); + $this->assertEquals( $correct, true ); + + $this->click( "link=Google" ); + $this->waitForPageToLoad( "600000" ); + + // Verify external link opens + $source = $this->getTitle(); + $correct = strstr( $source, "Google" ); + $this->assertEquals( $correct, true); + } + + // Add level 2 headline and verify output in the preview + public function testAddLevel2HeadLine() { + $blnElementPresent = False; + $blnTextPresent = False; + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-headline" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + $this->assertTrue($this->isElementPresent( "//div[@id='wikiPreview']/h2" )); + + // Verify level 2 headline displayed on mediawiki preview + $source = $this->getText( "//*[@id='Headline_text']" ); + $correct = strstr( $source, "Headline text" ); + $this->assertEquals( $correct, true ); + } + + // Add text with ignore wiki format and verify output the preview + public function testAddNoWikiFormat() { + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-nowiki']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify ignore wiki format text displayed on mediawiki preview + $source = $this->getText( "//div[@id='wikiPreview']/p" ); + $correct = strstr( $source, "Insert non-formatted text here" ); + $this->assertEquals( $correct, true ); + } + + // Add signature and verify output in the preview + public function testAddUserSignature() { + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-signature" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify signature displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $username = $this->getText( "//*[@id='pt-userpage']/a" ); + $correct = strstr( $source, $username ); + $this->assertEquals( $correct, true ); + } + + // Add horizontal line and verify output in the preview + public function testHorizontalLine() { + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-hr" ); + + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify horizontal line displayed on mediawiki preview + $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" )); + $this->deletePage( "new" ); + } +} diff --git a/maintenance/tests/selenium/suites/AddNewPageTestCase.php b/maintenance/tests/selenium/suites/AddNewPageTestCase.php new file mode 100644 index 00000000..423f2a2c --- /dev/null +++ b/maintenance/tests/selenium/suites/AddNewPageTestCase.php @@ -0,0 +1,65 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + + +class AddNewPageTestCase extends SeleniumTestCase { + + // Verify adding a new page + public function testAddNewPage() { + $newPage = "new"; + $displayName = "New"; + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "600000" ); + + // Verify 'Search results' text available + $source = $this->gettext( "firstHeading" ); + $correct = strstr( $source, "Search results" ); + $this->assertEquals( $correct, true); + + // Verify 'Create the page "<page name>" on this wiki' text available + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr ( $source, "Create the page \"New\" on this wiki!" ); + $this->assertEquals( $correct, true ); + + $this->click( "link=".$displayName ); + $this->waitForPageToLoad( "600000" ); + + $this->assertTrue($this->isElementPresent( "link=Create" )); + $this->type( "wpTextbox1", "add new test page" ); + $this->click( "wpSave" ); + + // Verify new page added + $source = $this->gettext( "firstHeading" ); + $correct = strstr ( $source, $displayName ); + $this->assertEquals( $correct, true ); + } +} diff --git a/maintenance/tests/selenium/suites/CreateAccountTestCase.php b/maintenance/tests/selenium/suites/CreateAccountTestCase.php new file mode 100644 index 00000000..1cfda2e0 --- /dev/null +++ b/maintenance/tests/selenium/suites/CreateAccountTestCase.php @@ -0,0 +1,114 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +Class CreateAccountTestCase extends SeleniumTestCase { + + // Change these values before run the test + private $userName = "yourname4000"; + private $password = "yourpass4000"; + + // Verify 'Log in/create account' link existance in Main page. + public function testMainPageLink() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + $this->assertTrue($this->isElementPresent( "link=Log in / create account" )); + } + + // Verify 'Create an account' link existance in 'Log in / create account' Page. + public function testCreateAccountPageLink() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + // click Log in / create account link to open Log in / create account' page + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + $this->assertTrue($this->isElementPresent( "link=Create an account" )); + } + + // Verify Create account + public function testCreateAccount() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + + $this->click( "link=Create an account" ); + $this->waitForPageToLoad( "30000" ); + + // Verify for blank user name + $this->type( "wpName2", "" ); + $this->click( "wpCreateaccount" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n You have not specified a valid user name.", + $this->getText( "//div[@id='bodyContent']/div[4]" )); + + // Verify for invalid user name + $this->type( "wpName2", "@" ); + $this->click("wpCreateaccount" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n You have not specified a valid user name.", + $this->getText( "//div[@id='bodyContent']/div[4]" )); + + // start of test for blank password + $this->type( "wpName2", $this->userName); + $this->type( "wpPassword2", "" ); + $this->click( "wpCreateaccount" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n Passwords must be at least 1 character.", + $this->getText("//div[@id='bodyContent']/div[4]" )); + + $this->type( "wpName2", $this->userName ); + $this->type( "wpPassword2", $this->password ); + $this->click( "wpCreateaccount" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n The passwords you entered do not match.", + $this->getText( "//div[@id='bodyContent']/div[4]" )); + + $this->type( "wpName2", $this->userName ); + $this->type( "wpPassword2", $this->password ); + $this->type( "wpRetype", $this->password ); + $this->click( "wpCreateaccount" ); + $this->waitForPageToLoad( "30000 "); + + // Verify successful account creation for valid combination of 'Username', 'Password', 'Retype password' + $this->assertEquals( "Welcome, ".ucfirst( $this->userName )."!", + $this->getText( "Welcome,_".ucfirst( $this->userName )."!" )); + } +} + diff --git a/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php b/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php new file mode 100644 index 00000000..40628986 --- /dev/null +++ b/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php @@ -0,0 +1,89 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + + +class DeletePageAdminTestCase extends SeleniumTestCase { + + // Verify adding a new page + public function testDeletePage() { + + + $newPage = "new"; + $displayName = "New"; + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=".$displayName ); + $this->waitForPageToLoad( "60000" ); + $this->type( "wpTextbox1", $newPage." text" ); + $this->click( "wpSave" ); + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "wpName1", $this->selenium->getUser() ); + $this->type( "wpPassword1", $this->selenium->getPass() ); + $this->click( "wpLoginAttempt" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "searchInput", "new" ); + $this->click( "searchGoButton"); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Delete' link displayed + $source = $this->gettext( "link=Delete" ); + $correct = strstr ( $source, "Delete" ); + $this->assertEquals($correct, true ); + + $this->click( "link=Delete" ); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Delete' button available + $this->assertTrue($this->isElementPresent( "wpConfirmB" )); + + $this->click( "wpConfirmB" ); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Action complete' text displayed + $source = $this->gettext( "firstHeading" ); + $correct = strstr ( $source, "Action complete" ); + $this->assertEquals( $correct, true ); + + // Verify '<Page Name> has been deleted. See deletion log for a record of recent deletions.' text displayed + $source = $this->gettext( "//div[@id='bodyContent']/p[1]" ); + $correct = strstr ( $source, "\"New\" has been deleted. See deletion log for a record of recent deletions." ); + $this->assertEquals( $correct, true ); + } +} diff --git a/maintenance/tests/selenium/suites/EmailPasswordTestCase.php b/maintenance/tests/selenium/suites/EmailPasswordTestCase.php new file mode 100644 index 00000000..8356f43a --- /dev/null +++ b/maintenance/tests/selenium/suites/EmailPasswordTestCase.php @@ -0,0 +1,81 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class EmailPasswordTestCase extends SeleniumTestCase { + + // change user name for each and every test (with in 24 hours) + private $userName = "test1"; + + public function testEmailPasswordButton() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + // click Log in / create account link to open Log in / create account' page + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + $this->assertTrue($this->isElementPresent( "wpMailmypassword" )); + } + + // Verify Email password functionality + public function testEmailPasswordMessages() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( "30000" ); + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + // click Log in / create account link to open Log in / create account' page + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "wpName1", "" ); + $this->click( "wpMailmypassword" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n You have not specified a valid user name.", + $this->getText("//div[@id='bodyContent']/div[4]")); + + $this->type( "wpName1", $this->userName ); + $this->click( "wpMailmypassword" ); + $this->waitForPageToLoad( "30000" ); + + // Can not run on localhost + $this->assertEquals( "A new password has been sent to the e-mail address registered for ".ucfirst($this->userName).". Please log in again after you receive it.", + $this->getText("//div[@id='bodyContent']/div[4]" )); + + $this->type( "wpName1", $this->userName ); + $this->click( "wpMailmypassword" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Login error\n A password reminder has already been sent, within the last 24 hours. To prevent abuse, only one password reminder will be sent per 24 hours.", + $this->getText( "//div[@id='bodyContent']/div[4]" )); + } +} + diff --git a/maintenance/tests/selenium/suites/MediaWikExtraTestSuite.php b/maintenance/tests/selenium/suites/MediaWikExtraTestSuite.php new file mode 100644 index 00000000..205cb332 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikExtraTestSuite.php @@ -0,0 +1,20 @@ +<?php + +class MediaWikExtraTestSuite extends SeleniumTestSuite { + public function setUp() { + $this->setLoginBeforeTests( true ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/MyContributionsTestCase.php', + 'maintenance/tests/selenium/suites/MyWatchListTestCase.php', + 'maintenance/tests/selenium/suites/UserPreferencesTestCase.php', + 'maintenance/tests/selenium/suites/MovePageTestCase.php', + 'maintenance/tests/selenium/suites/PageSearchTestCase.php', + 'maintenance/tests/selenium/suites/EmailPasswordTestCase.php', + 'maintenance/tests/selenium/suites/CreateAccountTestCase.php' + ); + parent::addTestFiles( $testFiles ); + } +} diff --git a/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php new file mode 100644 index 00000000..2803117d --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php @@ -0,0 +1,47 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class MediaWikiEditorConfig { + + public static function getSettings(&$includeFiles, &$globalConfigs) { + $includes = array( + //files that needed to be included would go here + 'maintenance/tests/selenium/suites/MediaWikiCommonFunction.php' + ); + $configs = array( + 'wgPageLoadTime' => "600000" + ); + $includeFiles = array_merge( $includeFiles, $includes ); + $globalConfigs = array_merge( $globalConfigs, $configs); + return true; + } +} + + + diff --git a/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php b/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php new file mode 100644 index 00000000..06046365 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php @@ -0,0 +1,18 @@ +<?php + +class MediaWikiEditorTestSuite extends SeleniumTestSuite { + public function setUp() { + $this->setLoginBeforeTests( true ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/AddNewPageTestCase.php', + 'maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php', + 'maintenance/tests/selenium/suites/PreviewPageTestCase.php', + 'maintenance/tests/selenium/suites/SavePageTestCase.php', + ); + parent::addTestFiles( $testFiles ); + } +} + diff --git a/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestCase.php b/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestCase.php new file mode 100644 index 00000000..7b9525af --- /dev/null +++ b/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestCase.php @@ -0,0 +1,69 @@ +<?php +/* + * Stub of tests be need as part of the hack-a-ton + */ +class MediawikiCoreSmokeTestCase extends SeleniumTestCase { + public function testUserLogin() { + + } + + public function testChangeUserPreference() { + + } + + /* + * TODO: generalize this test to be reusable for different skins + */ + public function testCreateNewPageVector() { + + } + + /* + * TODO: generalize this test to be reusable for different skins + */ + public function testEditExistingPageVector() { + + } + + /* + * TODO: generalize this test to be reusable for different skins + */ + public function testCreateNewPageMonobook() { + + } + + /* + * TODO: generalize this test to be reusable for different skins + */ + public function testEditExistingPageMonobook() { + + } + + public function testImageUpload() { + $this->login(); + $this->open( $this->getUrl() . + '/index.php?title=Special:Upload' ); + $this->type( 'wpUploadFile', dirname( __FILE__ ) . + "\\..\\data\\Wikipedia-logo-v2-de.png" ); + $this->check( 'wpIgnoreWarning' ); + $this->click( 'wpUpload' ); + $this->waitForPageToLoad( 30000 ); + + $this->assertSeleniumHTMLContains( + '//h1[@class="firstHeading"]', "Wikipedia-logo-v2-de.png" ); + + /* + $this->open( $this->getUrl() . '/index.php?title=Image:' + . ucfirst( $this->filename ) . '&action=delete' ); + $this->type( 'wpReason', 'Remove test file' ); + $this->click( 'mw-filedelete-submit' ); + $this->waitForPageToLoad( 10000 ); + + // Todo: This message is localized + $this->assertSeleniumHTMLContains( '//div[@id="bodyContent"]/p', + ucfirst( $this->filename ) . '.*has been deleted.' ); + */ + } + + +} diff --git a/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestSuite.php b/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestSuite.php new file mode 100644 index 00000000..76287b23 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediawikiCoreSmokeTestSuite.php @@ -0,0 +1,19 @@ +<?php +/* + * Stubs for now. We're going to start populating this test. + */ +class MediawikiCoreSmokeTestSuite extends SeleniumTestSuite +{ + public function setUp() { + $this->setLoginBeforeTests( false ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/MediawikiCoreSmokeTestCase.php' + ); + parent::addTestFiles( $testFiles ); + } + + +} diff --git a/maintenance/tests/selenium/suites/MovePageTestCase.php b/maintenance/tests/selenium/suites/MovePageTestCase.php new file mode 100644 index 00000000..d4d3b1f2 --- /dev/null +++ b/maintenance/tests/selenium/suites/MovePageTestCase.php @@ -0,0 +1,117 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class MovePageTestCase extends SeleniumTestCase { + + // Verify move(rename) wiki page + public function testMovePage() { + + $newPage = "mypage99"; + $displayName = "Mypage99"; + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=".$displayName ); + $this->waitForPageToLoad( "60000" ); + $this->type( "wpTextbox1", $newPage." text" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "60000" ); + + // Verify link 'Move' available + $this->assertTrue($this->isElementPresent( "link=Move" )); + + $this->click( "link=Move" ); + $this->waitForPageToLoad( "30000" ); + + // Verify correct page name displayed under 'Move Page' field + $this->assertEquals($displayName, + $this->getText("//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a")); + $movePageName = $this->getText( "//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a" ); + + // Verify 'To new title' field has current page name as the default name + $newTitle = $this->getValue( "wpNewTitle" ); + $correct = strstr( $movePageName , $newTitle ); + $this->assertEquals( $correct, true ); + + $this->type( "wpNewTitle", $displayName ); + $this->click( "wpMove" ); + $this->waitForPageToLoad( "30000" ); + + // Verify warning message for the same source and destination titles + $this->assertEquals( "Source and destination titles are the same; cannot move a page over itself.", + $this->getText("//div[@id='bodyContent']/p[4]/strong" )); + + // Verify warning message for the blank title + $this->type( "wpNewTitle", "" ); + $this->click( "wpMove" ); + $this->waitForPageToLoad( "30000" ); + + // Verify warning message for the blank title + $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.", + $this->getText( "//div[@id='bodyContent']/p[4]/strong" )); + + // Verify warning messages for the invalid titles + $this->type( "wpNewTitle", "# < > [ ] | { }" ); + $this->click( "wpMove" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.", + $this->getText( "//div[@id='bodyContent']/p[4]/strong" )); + + $this->type( "wpNewTitle", $displayName."move" ); + $this->click( "wpMove" ); + $this->waitForPageToLoad( "30000" ); + + // Verify move success message displayed correctly + $this->assertEquals( "\"".$displayName."\" has been moved to \"".$displayName."move"."\"", + $this->getText( "//div[@id='bodyContent']/p[1]/b" )); + + $this->type( "searchInput", $newPage."move" ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify search using new page name + $this->assertEquals( $displayName."move", $this->getText( "firstHeading" )); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify search using old page name + $redirectPageName = $this->getText( "//*[@id='contentSub']" ); + $this->assertEquals( "(Redirected from ".$displayName.")" , $redirectPageName ); + + // newpage delete + $this->deletePage( $newPage."move" ); + $this->deletePage( $newPage ); + } +} + diff --git a/maintenance/tests/selenium/suites/MyContributionsTestCase.php b/maintenance/tests/selenium/suites/MyContributionsTestCase.php new file mode 100644 index 00000000..95011c3b --- /dev/null +++ b/maintenance/tests/selenium/suites/MyContributionsTestCase.php @@ -0,0 +1,76 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class MyContributionsTestCase extends SeleniumTestCase { + + // Verify user contributions + public function testRecentChangesAvailability() { + + $newPage = "mypage999"; + $displayName = "Mypage999"; + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + + $this->type( "searchInput", $newPage); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "60000" ); + $this->click( "link=".$displayName ); + $this->waitForPageToLoad( "600000" ); + $this->type( "wpTextbox1", $newPage." text" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "60000" ); + + // Verify My contributions Link available + $this->assertTrue($this->isElementPresent( "link=My contributions" )); + + $this->click( "link=My contributions" ); + $this->waitForPageToLoad( "30000" ); + + // Verify recent page adding available on My Contributions list + $this->assertEquals( $displayName, $this->getText( "link=".$displayName )); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + + $this->click( "link=Edit" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "wpTextbox1", $newPage." text changed" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=My contributions" ); + $this->waitForPageToLoad( "30000" ); + + // Verify recent page changes available on My Contributions + $this->assertTrue($this->isTextPresent($displayName." (top)")); + $this->deletePage($newPage); + } +} + diff --git a/maintenance/tests/selenium/suites/MyWatchListTestCase.php b/maintenance/tests/selenium/suites/MyWatchListTestCase.php new file mode 100644 index 00000000..150c1f51 --- /dev/null +++ b/maintenance/tests/selenium/suites/MyWatchListTestCase.php @@ -0,0 +1,73 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + + +class MyWatchListTestCase extends SeleniumTestCase { + + // Verify user watchlist + public function testMyWatchlist() { + + $newPage = "mypage"; + $displayName = "Mypage"; + $wikiText = "watch page"; + + $this->open( $this->getUrl().'/index.php?title=Main_Page' ); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=".$displayName ); + $this->waitForPageToLoad( "600000" ); + + $this->click( "wpWatchthis" ); + $this->type( "wpTextbox1",$wikiText ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "30000" ); + + // Verify link 'My Watchlist' available + $this->assertTrue( $this->isElementPresent( "link=My watchlist" ) ); + + $this->click( "link=My watchlist" ); + $this->waitForPageToLoad( "30000" ); + + // Verify newly added page to the watchlist is available + $watchList = $this->getText( "//*[@id='bodyContent']" ); + $this->assertContains( $displayName, $watchList ); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "30000" ); + $this->click("link=Edit"); + $this->waitForPageToLoad( "30000" ); + $this->click( "wpWatchthis" ); + $this->click( "wpSave" ); + $this->deletePage( $newPage ); + } +} + diff --git a/maintenance/tests/selenium/suites/PageDeleteTestSuite.php b/maintenance/tests/selenium/suites/PageDeleteTestSuite.php new file mode 100644 index 00000000..2e535c11 --- /dev/null +++ b/maintenance/tests/selenium/suites/PageDeleteTestSuite.php @@ -0,0 +1,16 @@ +<?php + +class PageDeleteTestSuite extends SeleniumTestSuite { + public function setUp() { + $this->setLoginBeforeTests( true ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/DeletePageAdminTestCase.php' + ); + parent::addTestFiles( $testFiles ); + } + + +} diff --git a/maintenance/tests/selenium/suites/PageSearchTestCase.php b/maintenance/tests/selenium/suites/PageSearchTestCase.php new file mode 100644 index 00000000..e139f7a0 --- /dev/null +++ b/maintenance/tests/selenium/suites/PageSearchTestCase.php @@ -0,0 +1,105 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class PageSearchTestCase extends SeleniumTestCase { + + // Verify the functionality of the 'Go' button + public function testPageSearchBtnGo() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", "calcey qa" ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "600000" ); + + // Verify no page matched with the entered search text + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr ( $source, "Create the page \"Calcey qa\" on this wiki!" ); + $this->assertEquals( $correct, true ); + + $this->click( "link=Calcey qa" ); + $this->waitForPageToLoad( "600000" ); + + $this->type( "wpTextbox1", "Calcey QA team" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "600000" ); + + } + + // Verify the functionality of the 'Search' button + public function testPageSearchBtnSearch() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", "Calcey web" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify no page is available as the search text + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" ); + $correct = strstr ( $source, "Create the page \"Calcey web\" on this wiki!" ); + $this->assertEquals( $correct, true ); + + $this->click( "link=Calcey web" ); + $this->waitForPageToLoad( "600000" ); + + $this->type( "wpTextbox1", "Calcey web team" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "600000" ); + + // Verify saved page is opened when the exact page name is given + $this->type( "searchInput", "Calcey web" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify exact page matched with the entered search text using 'Search' button + $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." ); + $this->assertEquals( $correct, true ); + + // Verify resutls available when partial page name is entered as the search text + $this->type( "searchInput", "Calcey" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify text avaialble in the search result under the page titles + if($this->isElementPresent( "Page_title_matches" )) { + $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" ); + $this->assertContains( 'Calcey', $textPageTitle ); + } + + // Verify text avaialble in the search result under the page text + if($this->isElementPresent( "Page_text_matches" )) { + $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" ); + $this->assertContains( 'Calcey', $textPageText ); + } + $this->deletePage("Calcey QA"); + $this->deletePage("Calcey web"); + } +} diff --git a/maintenance/tests/selenium/suites/PreviewPageTestCase.php b/maintenance/tests/selenium/suites/PreviewPageTestCase.php new file mode 100644 index 00000000..b704bf39 --- /dev/null +++ b/maintenance/tests/selenium/suites/PreviewPageTestCase.php @@ -0,0 +1,53 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class PreviewPageTestCase extends SeleniumTestCase { + + // Verify adding a new page + public function testPreviewPage() { + $wikiText = "Adding this page to test the \n Preview button functionality"; + $newPage = "Test Preview Page"; + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->getNewPage( $newPage ); + $this->type( "wpTextbox1", $wikiText."" ); + $this->assertTrue($this->isElementPresent( "//*[@id='wpPreview']" )); + + $this->click( "wpPreview" ); + + // Verify saved page available + $source = $this->gettext( "firstHeading" ); + $correct = strstr( $source, "Test Preview Page" ); + $this->assertEquals( $correct, true); + + // Verify page content previewed succesfully + $contentOfPreviewPage = $this->getText( "//*[@id='content']" ); + $this->assertContains( $wikiText, $contentOfPreviewPage ); + } +} diff --git a/maintenance/tests/selenium/suites/SavePageTestCase.php b/maintenance/tests/selenium/suites/SavePageTestCase.php new file mode 100644 index 00000000..7f1a6924 --- /dev/null +++ b/maintenance/tests/selenium/suites/SavePageTestCase.php @@ -0,0 +1,58 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class SavePageTestCase extends SeleniumTestCase { + + // Verify adding a new page + public function testSavePage() { + $wikiText = "Adding this page to test the Save button functionality"; + $newPage = "Test Save Page"; + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->getNewPage($newPage); + $this->type("wpTextbox1", $wikiText); + + // verify 'Save' button available + $this->assertTrue($this->isElementPresent( "wpSave" )); + $this->click( "wpSave" ); + + // Verify saved page available + $source = $this->gettext( "firstHeading" ); + $correct = strstr( $source, "Test Save Page" ); + + // Verify Saved page name displayed correctly + $this->assertEquals( $correct, true ); + + // Verify page content saved succesfully + $contentOfSavedPage = $this->getText( "//*[@id='content']" ); + $this->assertContains( $wikiText, $contentOfSavedPage ); + $this->deletePage( $newPage ); + } +} diff --git a/maintenance/tests/selenium/suites/SimpleSeleniumConfig.php b/maintenance/tests/selenium/suites/SimpleSeleniumConfig.php new file mode 100644 index 00000000..cffa83c4 --- /dev/null +++ b/maintenance/tests/selenium/suites/SimpleSeleniumConfig.php @@ -0,0 +1,15 @@ +<?php +class SimpleSeleniumConfig { + + public static function getSettings(&$includeFiles, &$globalConfigs) { + $includes = array( + //files that needed to be included would go here + ); + $configs = array( + 'wgDefaultSkin' => 'chick' + ); + $includeFiles = array_merge( $includeFiles, $includes ); + $globalConfigs = array_merge( $globalConfigs, $configs); + return true; + } +}
\ No newline at end of file diff --git a/maintenance/tests/selenium/suites/SimpleSeleniumTestCase.php b/maintenance/tests/selenium/suites/SimpleSeleniumTestCase.php new file mode 100644 index 00000000..8f01b437 --- /dev/null +++ b/maintenance/tests/selenium/suites/SimpleSeleniumTestCase.php @@ -0,0 +1,30 @@ +<?php +/* + * This test case is part of the SimpleSeleniumTestSuite. + * Configuration for these tests are dosumented as part of SimpleSeleniumTestSuite.php + */ +class SimpleSeleniumTestCase extends SeleniumTestCase { + public function testBasic() { + $this->open( $this->getUrl() . + '/index.php?title=Selenium&action=edit' ); + $this->type( "wpTextbox1", "This is a basic test" ); + $this->click( "wpPreview" ); + $this->waitForPageToLoad( 10000 ); + + // check result + $source = $this->getText( "//div[@id='wikiPreview']/p" ); + $correct = strstr( $source, "This is a basic test" ); + $this->assertEquals( $correct, true ); + } + + /* + * All this test really does is verify that a global var was set. + * It depends on $wgDefaultSkin = 'chick'; being set + */ + public function testGlobalVariableForDefaultSkin() { + $this->open( $this->getUrl() . '/index.php?&action=purge' ); + $bodyClass = $this->getAttribute( "//body/@class" ); + $this-> assertContains('skin-chick', $bodyClass, 'Chick skin not set'); + } + +} diff --git a/maintenance/tests/selenium/suites/SimpleSeleniumTestSuite.php b/maintenance/tests/selenium/suites/SimpleSeleniumTestSuite.php new file mode 100644 index 00000000..a04f33ed --- /dev/null +++ b/maintenance/tests/selenium/suites/SimpleSeleniumTestSuite.php @@ -0,0 +1,26 @@ +<?php +/* + * Sample test suite. + * Two ways to configure MW for these tests + * 1) If you are running multiple test suites, add the following in LocalSettings.php + * require_once("maintenance/tests/selenium/SimpleSeleniumConfig.php"); + * $wgSeleniumTestConfigs['SimpleSeleniumTestSuite'] = 'SimpleSeleniumConfig::getSettings'; + * OR + * 2) Add the following to your Localsettings.php + * $wgDefaultSkin = 'chick'; + */ +class SimpleSeleniumTestSuite extends SeleniumTestSuite +{ + public function setUp() { + $this->setLoginBeforeTests( false ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/SimpleSeleniumTestCase.php' + ); + parent::addTestFiles( $testFiles ); + } + + +} diff --git a/maintenance/tests/selenium/suites/UserPreferencesTestCase.php b/maintenance/tests/selenium/suites/UserPreferencesTestCase.php new file mode 100644 index 00000000..12824307 --- /dev/null +++ b/maintenance/tests/selenium/suites/UserPreferencesTestCase.php @@ -0,0 +1,179 @@ +<?php + +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com> + * http://citizendium.org/ + * + * 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 + * + */ + +class UserPreferencesTestCase extends SeleniumTestCase { + + // Verify user information + public function testUserInfoDisplay() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + + // Verify correct username displayed in User Preferences + $this->assertEquals( $this->getText( "//li[@id='pt-userpage']/a" ), + $this->getText( "//table[@id='mw-htmlform-info']/tbody/tr[1]/td[2]" )); + + // Verify existing Signature Displayed correctly + $this->assertEquals( $this->selenium->getUser(), + $this->getTable( "mw-htmlform-signature.0.1" ) ); + } + + // Verify change password + public function testChangePassword() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + + $this->click( "link=Change password" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "wpPassword", "12345" ); + $this->type( "wpNewPassword", "54321" ); + $this->type( "wpRetype", "54321" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( "30000" ); + + $this->assertEquals( "Preferences", $this->getText( "firstHeading" )); + + $this->click( "link=Change password" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "wpPassword", "54321" ); + $this->type( "wpNewPassword", "12345" ); + $this->type( "wpRetype", "12345" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( "30000" ); + $this->assertEquals( "Preferences", $this->getText( "firstHeading" )); + + $this->click( "link=Change password" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "wpPassword", "54321" ); + $this->type( "wpNewPassword", "12345" ); + $this->type( "wpRetype", "12345" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( "30000" ); + } + + // Verify successful preferences save + public function testSuccessfullSave() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "mw-input-realname", "Test User" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( "30000" ); + + // Verify "Your preferences have been saved." message + $this->assertEquals( "Your preferences have been saved.", + $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" )); + $this->type( "mw-input-realname", "" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( "30000" ); + + } + + // Verify change signature + public function testChangeSignature() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + + $this->type( "mw-input-nickname", "TestSignature" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( "30000" ); + + // Verify change user signature + $this->assertEquals( "TestSignature", $this->getText( "link=TestSignature" )); + $this->type( "mw-input-nickname", "Test" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad("30000"); + } + + // Verify change date format + public function testChangeDateFormatTimeZone() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=Date and time" ); + $this->waitForPageToLoad( "30000" ); + + $this->click( "mw-input-date-dmy" ); + $this->select( "mw-input-timecorrection", "label=Asia/Colombo" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( "30000" ); + + // Verify Date format and time zome saved + $this->assertEquals( "Your preferences have been saved.", + $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" )); + } + + // Verify restoring all default settings + public function testSetAllDefault() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( "link=My preferences" ); + $this->waitForPageToLoad( "30000" ); + + // Verify restoring all default settings + $this->assertEquals( "Restore all default settings", + $this->getText( "link=Restore all default settings" )); + + $this->click("//*[@id='preferences']/div/a"); + $this->waitForPageToLoad("30000"); + + // Verify 'This can not be undone' warning message displayed + $this->assertTrue($this->isElementPresent("//input[@value='Restore all default settings']")); + + // Verify 'Restore all default settings' button available + $this->assertEquals("You can use this page to reset your preferences to the site defaults. This cannot be undone.", + $this->getText("//div[@id='bodyContent']/p")); + + $this->click("//input[@value='Restore all default settings']"); + $this->waitForPageToLoad("30000"); + + // Verify preferences saved successfully + $this->assertEquals("Your preferences have been saved.", + $this->getText("//div[@id='bodyContent']/div[4]/strong/p")); + } +} + |