From a477c099cad10791148b1475107e0fde815dacad Mon Sep 17 00:00:00 2001 From: nadeesha Date: Fri, 3 Dec 2010 14:10:09 +0000 Subject: [PATCH] Added test scripts for wiki editor additional features and updated scripts on wiki basic editor. MediaWikiCommonFunction.php is deleted, since it is no longer used by the scripts. --- .../suites/AddContentToNewPageTestCase.php | 432 ++++++++---------- .../selenium/suites/AddNewPageTestCase.php | 120 ++--- .../selenium/suites/CreateAccountTestCase.php | 114 +++++ .../suites/DeletePageAdminTestCase.php | 146 +++--- .../selenium/suites/EmailPasswordTestCase.php | 81 ++++ .../suites/MediaWikExtraTestSuite.php | 20 + .../selenium/suites/MediaWikiCommonFunc.php | 77 ---- .../selenium/suites/MediaWikiEditorConfig.php | 59 ++- .../suites/MediaWikiEditorTestSuite.php | 42 +- .../selenium/suites/MovePageTestCase.php | 117 +++++ .../suites/MyContributionsTestCase.php | 76 +++ .../selenium/suites/MyWatchListTestCase.php | 73 +++ .../selenium/suites/PageDeleteTestSuite.php | 16 + .../selenium/suites/PageSearchTestCase.php | 222 +++++---- .../selenium/suites/PreviewPageTestCase.php | 53 +++ .../selenium/suites/SavePageTestCase.php | 58 +++ .../suites/UserPreferencesTestCase.php | 179 ++++++++ 17 files changed, 1273 insertions(+), 612 deletions(-) create mode 100644 maintenance/tests/selenium/suites/CreateAccountTestCase.php create mode 100644 maintenance/tests/selenium/suites/EmailPasswordTestCase.php create mode 100644 maintenance/tests/selenium/suites/MediaWikExtraTestSuite.php delete mode 100644 maintenance/tests/selenium/suites/MediaWikiCommonFunc.php create mode 100644 maintenance/tests/selenium/suites/MovePageTestCase.php create mode 100644 maintenance/tests/selenium/suites/MyContributionsTestCase.php create mode 100644 maintenance/tests/selenium/suites/MyWatchListTestCase.php create mode 100644 maintenance/tests/selenium/suites/PageDeleteTestSuite.php create mode 100644 maintenance/tests/selenium/suites/PreviewPageTestCase.php create mode 100644 maintenance/tests/selenium/suites/SavePageTestCase.php create mode 100644 maintenance/tests/selenium/suites/UserPreferencesTestCase.php diff --git a/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php index d217f69b42..dd4bc005dc 100644 --- a/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php +++ b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php @@ -1,258 +1,182 @@ getExistingPage(); - $this->clickEditLink(); - $this->loadWikiEditor(); - $this->clearWikiEditor(); - $this->click( "//*[@id='mw-editbutton-bold']" ); - $this->clickShowPreviewBtn(); - $this->waitForPageToLoad( "600000" ); - - try{ - $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/b")); - $blnElementPresent = True; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnElementPresent = False; - } - - try{ - $this->assertTrue($this->isTextPresent( "Bold text" )); - $blnTextPresent = True; - - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnTextPresent = False; - } - - // Verify bold text displayed on mediawiki preview - if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){ - echo "\n Pass : Bold text displayed in the preview \n"; - } - else{ - echo "\n Fail : Bold text displayed in the preview \n"; - } - } - - // 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 - try{ - $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/i")); - $blnElementPresent = True; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnElementPresent = False; - } - - try{ - $this->assertTrue($this->isTextPresent( "Italic text" )); - $blnTextPresent = True; - - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnTextPresent = False; - } - - // Verify italic text displayed on mediawiki preview - if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){ - echo "\n Pass : Italic text displayed in the preview \n"; - } - else{ - echo "\n Fail : Italic text displayed in the preview \n"; - } - - } - - // 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" ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Internal link displayed in the preview \n"; - - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Pass : Internal link displayed in the preview \n"; - } - - $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" ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Internal link opened as a new page in the editing mode \n"; - - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : Internal link opened as a new page in the editing mode \n"; - } - } - - // 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" ); - - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : External link displayed in the preview \n"; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : External link displayed in thw preview \n"; - } - - $this->click( "link=Google" ); - $this->waitForPageToLoad( "600000" ); - - // Verify external link opens - $source = $this->getTitle(); - $correct = strstr( $source, "Google" ); - try{ - $this->assertEquals( $correct, true); - echo "\n Pass : External link opened \n"; - - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : External link opened \n"; - } - - } - - // 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" ); - - try { - $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/h2")); - $blnElementPresent = True; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnElementPresent = False; - } - - try{ - $source = $this->getText( "//*[@id='Headline_text']" ); - $correct = strstr( $source, "Headline text" ); - $this->assertEquals( $correct, true ); - $blnTextPresent = True; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - $blnTextPresent = False; - } - - if(($blnElementPresent = True) && ($blnTextPresent = True)){ - echo "\n Pass : Headline text displayed in the preview \n"; - } - else{ - echo "\n Fail : Headline text displayed in the preview \n"; - } - } - - // 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" ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Text available without wiki formats in the preview \n "; - - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : Text available without wiki formats in the preview\n "; - } - } - - // 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 ); - - try{ - $this->assertEquals( $correct, true); - echo "\n Pass : Correct name displayed in the preview \n "; - - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : Correct name displayed in the preview \n "; - } - } - - // 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" ); +/** + * Selenium server manager + * + * @file + * @ingroup Maintenance + * Copyright (C) 2010 Dan Nessett + * 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 + * + */ - // Verify horizontal line displayed on mediawiki preview - try{ - $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" )); - echo "\n Pass: Horizontal line displayed in the preview \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : Horizontal line displayed in the preview \n "; - } - } - - } +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 index 5098052f13..423f2a2c6a 100644 --- a/maintenance/tests/selenium/suites/AddNewPageTestCase.php +++ b/maintenance/tests/selenium/suites/AddNewPageTestCase.php @@ -1,61 +1,65 @@ + * 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() { - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->type("searchInput", "new"); - $this->click("searchGoButton"); - $this->waitForPageToLoad("600000"); - - // Verify 'Search results' text available - $source = $this->gettext( "firstHeading" ); - $correct = strstr( $source, "Search results"); - try{ - $this->assertEquals( $correct, true); - echo "\n Pass : Text'Search results' displayed \n"; - - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : Text' Search results' displayed \n" ; - } - - // Verify 'Create the page "" 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!" ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Text 'Create the page \"New\" on this wiki!' displayed \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : Text 'Create the page \"New\" on this wiki!' displayed \n"; - } - - $this->click("link=New"); - $this->waitForPageToLoad("600000"); - - // Verify 'Create' tab available - try{ - $this->assertTrue($this->isElementPresent("link=Create")); - echo "\n Pass : 'Create' tab displayed \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e) { - echo "\n Fail : 'Create' tab displayed \n"; - } - - $this->type("wpTextbox1", "add new test page"); - $this->click("wpSave"); - - // Verify new page added - $source = $this->gettext( "firstHeading" ); - $correct = strstr ( $source, "New" ); - try{ - $this->assertEquals( $correct, true); - echo "\n Pass : New page added \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : New page added \n"; - } - } + + +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 "" 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 0000000000..ec735e0ba1 --- /dev/null +++ b/maintenance/tests/selenium/suites/CreateAccountTestCase.php @@ -0,0 +1,114 @@ + + * 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 index 659cc06ca9..d2a821556d 100644 --- a/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php +++ b/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php @@ -1,68 +1,90 @@ + * 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() { - $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", "nadeesha" ); - $this->type( "wpPassword1", "12345" ); - $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" ); - try{ - $this->assertEquals( $correct, true); - echo "\n Pass : 'Delete' link displayed \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Fail : 'Delete' link displayed \n"; - } - $this->click( "link=Delete" ); - $this->waitForPageToLoad( "30000" ); - // Verify 'Delete' button available - $this->assertTrue($this->isElementPresent( "wpConfirmB" )); +require_once("maintenance/tests/selenium/suites/MediaWikiCommonFunction.php"); + +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" ); - try{ - $this->assertTrue($this->isElementPresent( "wpConfirmB" )); - echo "\n Pass : 'Delete' button available \n"; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : 'Delete' button available \n"; - } - $this->click( "wpConfirmB" ); - $this->waitForPageToLoad( "30000" ); - - // Verify 'Action complete' text displayed - $source = $this->gettext( "firstHeading" ); - $correct = strstr ( $source, "Action complete" ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : 'Action complete' text displayed \n"; - }catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : 'Action complete' text displayed \n"; - } + // Verify 'Action complete' text displayed + $source = $this->gettext( "firstHeading" ); + $correct = strstr ( $source, "Action complete" ); + $this->assertEquals( $correct, true ); - // Verify ' 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." ); - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Page deleted successfully \n"; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : Page deleted successfully \n"; - } - } + // Verify ' 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 0000000000..facefea326 --- /dev/null +++ b/maintenance/tests/selenium/suites/EmailPasswordTestCase.php @@ -0,0 +1,81 @@ + + * 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 0000000000..a70ddfe463 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikExtraTestSuite.php @@ -0,0 +1,20 @@ +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/MediaWikiCommonFunc.php b/maintenance/tests/selenium/suites/MediaWikiCommonFunc.php deleted file mode 100644 index cb825b462e..0000000000 --- a/maintenance/tests/selenium/suites/MediaWikiCommonFunc.php +++ /dev/null @@ -1,77 +0,0 @@ -open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->type("searchInput", "new" ); - $this->click("searchGoButton"); - $this->waitForPageToLoad("30000"); - } - - // Creating new page - public function getNewPage($pageName){ - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->type("searchInput", $pageName ); - $this->click("searchGoButton"); - $this->waitForPageToLoad("30000"); - $this->click("link=".$pageName); - $this->waitForPageToLoad("600000"); - } - - // Deleting the given page - public function deletePage($pageName){ - $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", "nadeesha" ); - $this->type( "wpPassword1", "12345" ); - $this->click( "wpLoginAttempt" ); - $this->waitForPageToLoad( "30000" ); - $this->type( "searchInput", $pageName ); - $this->click( "searchGoButton"); - $this->waitForPageToLoad( "30000" ); - $this->click( "link=Delete" ); - $this->waitForPageToLoad( "30000" ); - $this->click( "wpConfirmB" ); - $this->waitForPageToLoad( "30000" ); - } - - // Loading the mediawiki editor - public function loadWikiEditor(){ - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - } - - // Clear the content of the mediawiki editor - public function clearWikiEditor(){ - $this->type("wpTextbox1", ""); - } - - // Click on the 'Show preview' button of the mediawiki editor - public function clickShowPreviewBtn(){ - $this->click("wpPreview"); - } - - // Click on the 'Save Page' button of the mediawiki editor - public function clickSavePageBtn(){ - $this->click("wpSave"); - } - - // Click on the 'Edit' link - public function clickEditLink(){ - $this->click("link=Edit"); - $this->waitForPageToLoad("30000"); - } - - - -} diff --git a/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php index e2258445e5..2803117deb 100644 --- a/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php +++ b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php @@ -1,16 +1,47 @@ + * 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/MediaWikiCommonFunc.php' - ); - $configs = array( - 'wgDefaultSkin' => 'chick' - ); - $includeFiles = array_merge( $includeFiles, $includes ); - $globalConfigs = array_merge( $globalConfigs, $configs); - return true; - } -} \ No newline at end of file + + 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 index b44584a2bd..06046365f1 100644 --- a/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php +++ b/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php @@ -1,30 +1,18 @@ 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/DeletePageAdminTestCase.php', - 'maintenance/tests/selenium/suites/PageSearchTestCase.php' - - ); - parent::addTestFiles( $testFiles ); - } - +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/MovePageTestCase.php b/maintenance/tests/selenium/suites/MovePageTestCase.php new file mode 100644 index 0000000000..caf4bd5589 --- /dev/null +++ b/maintenance/tests/selenium/suites/MovePageTestCase.php @@ -0,0 +1,117 @@ + + * 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 0000000000..e773efc756 --- /dev/null +++ b/maintenance/tests/selenium/suites/MyContributionsTestCase.php @@ -0,0 +1,76 @@ + + * 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 0000000000..1281c1b3b6 --- /dev/null +++ b/maintenance/tests/selenium/suites/MyWatchListTestCase.php @@ -0,0 +1,73 @@ + + * 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 0000000000..8c215521e6 --- /dev/null +++ b/maintenance/tests/selenium/suites/PageDeleteTestSuite.php @@ -0,0 +1,16 @@ +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 index 729e8d1431..e139f7a037 100644 --- a/maintenance/tests/selenium/suites/PageSearchTestCase.php +++ b/maintenance/tests/selenium/suites/PageSearchTestCase.php @@ -1,123 +1,105 @@ + * 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!" ); - - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : No page matched with the entered search text using the 'Go' button \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Pass : No page matched with the entered search text using the 'Go' button \n"; - } - - $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!" ); - - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : No page matched with the entered search text using the 'Search' button \n"; - } catch (PHPUnit_Framework_AssertionFailedError $e){ - echo "\n Pass : No page matched with the entered search text using the 'Search' button \n"; - } - - $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" ); - - $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" ); - $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." ); - - try{ - $this->assertEquals( $correct, true ); - echo "\n Pass : Exact page matched with the entered search text using 'Search' button \n"; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : Exact page matched with the entered search text using 'Search' button \n"; - } - - - // 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" )){ - try{ - $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" ); - $this->assertContains( 'Calcey', $textPageTitle ); - echo "\n Pass : Results displayed under 'Page title matches' heading for the partial title match match using the 'Search' button\n"; - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : Results displayed under 'Page title matches' heading for the partial title match match using the 'Search' button \n"; - } - } - else{ - echo "\n Pass : No results avaialble for the 'Page title matches' heading for the partial title match using the 'Search' button \n"; - } - - // Verify text avaialble in the search result under the page text - if($this->isElementPresent( "Page_text_matches" )){ - try{ - $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" ); - $this->assertContains( 'Calcey', $textPageText ); - - echo "\n Pass : Results displayed under 'Page text matches' heading for the partial text match using the 'Search' button \n"; - - } catch ( PHPUnit_Framework_AssertionFailedError $e ){ - echo "\n Fail : Results displayed under 'Page text matches' heading for the partial text match using the 'Search' button \n"; - } - } - else{ - echo "\n Pass : No results avaialble for the 'Page text matches' heading for the partial title match using the 'Search' button\n"; - } - $this->deletePage("Calcey QA"); - $this->deletePage("Calcey web"); - - } - - - + +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 0000000000..aeb432422e --- /dev/null +++ b/maintenance/tests/selenium/suites/PreviewPageTestCase.php @@ -0,0 +1,53 @@ + + * 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 0000000000..2b9dcadaa2 --- /dev/null +++ b/maintenance/tests/selenium/suites/SavePageTestCase.php @@ -0,0 +1,58 @@ + + * 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/UserPreferencesTestCase.php b/maintenance/tests/selenium/suites/UserPreferencesTestCase.php new file mode 100644 index 0000000000..c58b5ff29f --- /dev/null +++ b/maintenance/tests/selenium/suites/UserPreferencesTestCase.php @@ -0,0 +1,179 @@ + + * 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")); + } +} +?> -- 2.20.1