From 63fffc4fcbc7c79a0b5440dba8785951b3886006 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 15 Feb 2013 12:23:15 +0100 Subject: [PATCH] Update formatting 10 of n. Change-Id: I9c17088ac063c14544484176daa00272dcd607b8 --- .../maintenance/backupTextPassTest.php | 137 ++- ...ikiErrorsConnectToDatabasePageTestCase.php | 191 ++-- .../MediaWikiErrorsNamepageTestCase.php | 180 ++-- .../MediaWikiHelpFieldHintTestCase.php | 195 ++-- .../MediaWikiInstallationCommonFunction.php | 477 +++++---- ...diaWikiUpgradeExistingDatabaseTestCase.php | 158 +-- .../MediaWikiUserInterfaceTestCase.php | 953 +++++++++--------- .../suites/AddContentToNewPageTestCase.php | 299 +++--- .../selenium/suites/CreateAccountTestCase.php | 165 ++- tests/selenium/suites/MovePageTestCase.php | 170 ++-- tests/selenium/suites/PageSearchTestCase.php | 147 ++- .../suites/UserPreferencesTestCase.php | 291 +++--- tests/testHelpers.inc | 122 +-- 13 files changed, 1700 insertions(+), 1785 deletions(-) diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index 2a12806ecd..0962344591 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -65,7 +65,7 @@ class TextPassDumperTest extends DumpTestCase { if ( $ns === NS_TALK ) { //@todo: work around this. throw new MWException( "The default wikitext namespace is the talk namespace. " - . " We can't currently deal with that."); + . " We can't currently deal with that." ); } $title = Title::newFromText( 'BackupDumperTestP1', NS_TALK ); @@ -101,8 +101,8 @@ class TextPassDumperTest extends DumpTestCase { // Setting up the dump $nameStub = $this->setUpStub(); $nameFull = $this->getNewTempFile(); - $dumper = new TextPassDumper( array ( "--stub=file:" . $nameStub, - "--output=file:" . $nameFull ) ); + $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub, + "--output=file:" . $nameFull ) ); $dumper->reporting = false; $dumper->setDb( $this->db ); @@ -164,8 +164,8 @@ class TextPassDumperTest extends DumpTestCase { // Setting up of the dump $nameStub = $this->setUpStub(); $nameFull = $this->getNewTempFile(); - $dumper = new TextPassDumper( array ( "--stub=file:" - . $nameStub, "--output=file:" . $nameFull ) ); + $dumper = new TextPassDumper( array( "--stub=file:" + . $nameStub, "--output=file:" . $nameFull ) ); $dumper->prefetch = $prefetchMock; $dumper->reporting = false; $dumper->setDb( $this->db ); @@ -250,10 +250,10 @@ class TextPassDumperTest extends DumpTestCase { $this->assertTrue( wfMkdirParents( $nameOutputDir ), "Creating temporary output directory " ); $this->setUpStub( $nameStub, $iterations ); - $dumper = new TextPassDumper( array ( "--stub=file:" . $nameStub, - "--output=" . $checkpointFormat . ":" . $nameOutputDir . "/full", - "--maxtime=1" /*This is in minutes. Fixup is below*/, - "--checkpointfile=checkpoint-%s-%s.xml.gz" ) ); + $dumper = new TextPassDumper( array( "--stub=file:" . $nameStub, + "--output=" . $checkpointFormat . ":" . $nameOutputDir . "/full", + "--maxtime=1" /*This is in minutes. Fixup is below*/, + "--checkpointfile=checkpoint-%s-%s.xml.gz" ) ); $dumper->setDb( $this->db ); $dumper->maxTimeAllowed = $checkpointAfter; // Patching maxTime from 1 minute $dumper->stderr = $stderr; @@ -283,7 +283,7 @@ class TextPassDumperTest extends DumpTestCase { $this->assertLessThan( 50000, $iterations, "Emergency stop against infinitely increasing iteration " - . "count ( last duration: $lastDuration )" ); + . "count ( last duration: $lastDuration )" ); } } @@ -300,11 +300,11 @@ class TextPassDumperTest extends DumpTestCase { // Each run of the following loop body tries to handle exactly 1 /page/ (not // iteration of stub content). $i is only increased after having treated page 4. - for ( $i = 0 ; $i < $iterations ; ) { + for ( $i = 0; $i < $iterations; ) { // 1. Assuring a file is opened and ready. Skipping across header if // necessary. - if ( ! $fileOpened ) { + if ( !$fileOpened ) { $this->assertNotEmpty( $files, "No more existing dump files, " . "but not yet all pages found" ); $fname = array_shift( $files ); @@ -323,65 +323,65 @@ class TextPassDumperTest extends DumpTestCase { // 2. Performing a single page check switch ( $lookingForPage ) { - case 1: - // Page 1 - $this->assertPageStart( $this->pageId1 + $i * self::$numOfPages, NS_MAIN, - "BackupDumperTestP1" ); - $this->assertRevision( $this->revId1_1 + $i * self::$numOfRevs, "BackupDumperTestP1Summary1", - $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87", - "BackupDumperTestP1Text1" ); - $this->assertPageEnd(); - - $lookingForPage = 2; - break; - - case 2: - // Page 2 - $this->assertPageStart( $this->pageId2 + $i * self::$numOfPages, NS_MAIN, - "BackupDumperTestP2" ); - $this->assertRevision( $this->revId2_1 + $i * self::$numOfRevs, "BackupDumperTestP2Summary1", - $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", - "BackupDumperTestP2Text1" ); - $this->assertRevision( $this->revId2_2 + $i * self::$numOfRevs, "BackupDumperTestP2Summary2", - $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", - "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs ); - $this->assertRevision( $this->revId2_3 + $i * self::$numOfRevs, "BackupDumperTestP2Summary3", - $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", - "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs ); - $this->assertRevision( $this->revId2_4 + $i * self::$numOfRevs, - "BackupDumperTestP2Summary4 extra", - $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", - "BackupDumperTestP2Text4 some additional Text", - $this->revId2_3 + $i * self::$numOfRevs ); - $this->assertPageEnd(); - - $lookingForPage = 4; - break; - - case 4: - // Page 4 - $this->assertPageStart( $this->pageId4 + $i * self::$numOfPages, NS_TALK, - "Talk:BackupDumperTestP1" ); - $this->assertRevision( $this->revId4_1 + $i * self::$numOfRevs, - "Talk BackupDumperTestP1 Summary1", - $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe", - "Talk about BackupDumperTestP1 Text1" ); - $this->assertPageEnd(); - - $lookingForPage = 1; - - // We dealt with the whole iteration. - $i++; - break; - - default: - $this->fail( "Bad setting for lookingForPage ($lookingForPage)" ); + case 1: + // Page 1 + $this->assertPageStart( $this->pageId1 + $i * self::$numOfPages, NS_MAIN, + "BackupDumperTestP1" ); + $this->assertRevision( $this->revId1_1 + $i * self::$numOfRevs, "BackupDumperTestP1Summary1", + $this->textId1_1, false, "0bolhl6ol7i6x0e7yq91gxgaan39j87", + "BackupDumperTestP1Text1" ); + $this->assertPageEnd(); + + $lookingForPage = 2; + break; + + case 2: + // Page 2 + $this->assertPageStart( $this->pageId2 + $i * self::$numOfPages, NS_MAIN, + "BackupDumperTestP2" ); + $this->assertRevision( $this->revId2_1 + $i * self::$numOfRevs, "BackupDumperTestP2Summary1", + $this->textId2_1, false, "jprywrymfhysqllua29tj3sc7z39dl2", + "BackupDumperTestP2Text1" ); + $this->assertRevision( $this->revId2_2 + $i * self::$numOfRevs, "BackupDumperTestP2Summary2", + $this->textId2_2, false, "b7vj5ks32po5m1z1t1br4o7scdwwy95", + "BackupDumperTestP2Text2", $this->revId2_1 + $i * self::$numOfRevs ); + $this->assertRevision( $this->revId2_3 + $i * self::$numOfRevs, "BackupDumperTestP2Summary3", + $this->textId2_3, false, "jfunqmh1ssfb8rs43r19w98k28gg56r", + "BackupDumperTestP2Text3", $this->revId2_2 + $i * self::$numOfRevs ); + $this->assertRevision( $this->revId2_4 + $i * self::$numOfRevs, + "BackupDumperTestP2Summary4 extra", + $this->textId2_4, false, "6o1ciaxa6pybnqprmungwofc4lv00wv", + "BackupDumperTestP2Text4 some additional Text", + $this->revId2_3 + $i * self::$numOfRevs ); + $this->assertPageEnd(); + + $lookingForPage = 4; + break; + + case 4: + // Page 4 + $this->assertPageStart( $this->pageId4 + $i * self::$numOfPages, NS_TALK, + "Talk:BackupDumperTestP1" ); + $this->assertRevision( $this->revId4_1 + $i * self::$numOfRevs, + "Talk BackupDumperTestP1 Summary1", + $this->textId4_1, false, "nktofwzd0tl192k3zfepmlzxoax1lpe", + "Talk about BackupDumperTestP1 Text1" ); + $this->assertPageEnd(); + + $lookingForPage = 1; + + // We dealt with the whole iteration. + $i++; + break; + + default: + $this->fail( "Bad setting for lookingForPage ($lookingForPage)" ); } // 3. Checking for the end of the current checkpoint file if ( $this->xml->nodeType == XMLReader::END_ELEMENT - && $this->xml->name == "mediawiki" ) { - + && $this->xml->name == "mediawiki" + ) { $this->assertDumpEnd(); $fileOpened = false; } @@ -578,8 +578,7 @@ class TextPassDumperTest extends DumpTestCase { } $content .= $tail; $this->assertEquals( strlen( $content ), file_put_contents( - $fname, $content ), "Length of prepared stub" ); + $fname, $content ), "Length of prepared stub" ); return $fname; } - } diff --git a/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php b/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php index 825ca424a9..7eb6d384d8 100644 --- a/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php +++ b/tests/selenium/installer/MediaWikiErrorsConnectToDatabasePageTestCase.php @@ -34,103 +34,102 @@ require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' ); * Test Case ID : 09 (http://www.mediawiki.org/wiki/New_installer/Test_plan) * Test Case Name : Invalid/ blank values for fields in 'Connect to database' page. * Version : MediaWiki 1.18alpha -*/ + */ class MediaWikiErrorsConnectToDatabasePageTestCase extends MediaWikiInstallationCommonFunction { - function setUp() { - parent::setUp(); - } - - // Verify warning messages for the 'Connet to database' page - public function testErrorsConnectToDatabasePage() { - - parent::navigateConnetToDatabasePage(); - - // Verify warning mesage for invalid database host - $this->type( "mysql_wgDBserver", INVALID_DB_HOST ); - parent::clickContinueButton(); - $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (".INVALID_DB_HOST.").", - $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); - $this->assertEquals( "Check the host, username and password below and try again.", - $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); - // Verify warning message for the blank database host - $this->type( "mysql_wgDBserver", "" ); - parent::clickContinueButton(); - $this->assertEquals( "MySQL 4.0.14 or later is required, you have .", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - // Valid Database Host - $this->type( "mysql_wgDBserver", VALID_DB_HOST ); - - // Verify warning message for the invalid database name - $this->type( "mysql_wgDBname", INVALID_DB_NAME ); - parent::clickContinueButton(); - $this->assertEquals( "Invalid database name \"".INVALID_DB_NAME."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", - $this->getText( LINK_DIV."div[2]/div[2]/p" )); - - // Verify warning message for the blank database name - $this->type( "mysql_wgDBname", ""); - parent::clickContinueButton(); - $this->assertEquals( "You must enter a value for \"Database name\"", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - // valid Database name - $this->type( "mysql_wgDBname", VALID_DB_NAME); - - // Verify warning message for the invalid databaase prefix - $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX ); - parent::clickContinueButton(); - $this->assertEquals( "Invalid database prefix \"".INVALID_DB_PREFIX."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - // Valid Database prefix - $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX ); - - // Verify warning message for the invalid database user name - $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); - parent::clickContinueButton(); - $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: NO) (localhost).", - $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); - $this->assertEquals( "Check the host, username and password below and try again.", - $this->getText( LINK_DIV."div[2]/div[2]/p[2]")); - - // Verify warning message for the blank database user name - $this->type( "mysql__InstallUser", "" ); - parent::clickContinueButton(); - $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).", - $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); - $this->assertEquals( "Check the host, username and password below and try again.", - $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); - - // Valid Database username - $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); - - // Verify warning message for the invalid password - $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); - parent::clickContinueButton(); - - $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).", - $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); - $this->assertEquals( "Check the host, username and password below and try again.", - $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); - - // Verify warning message for the invalid username and password - $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); - $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); - parent::clickContinueButton(); - $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: YES) (localhost).", - $this->getText( LINK_DIV."div[2]/div[2]/p[1]" )); - $this->assertEquals( "Check the host, username and password below and try again.", - $this->getText( LINK_DIV."div[2]/div[2]/p[2]" )); - - // Valid username and valid password - $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); - $this->type( "mysql__InstallPassword", "" ); - parent::clickContinueButton(); - - // successfully completes the 'Connect to database' page - $this->assertEquals( "Database settings", - $this->getText( LINK_DIV."h2" )); - } + function setUp() { + parent::setUp(); + } + + // Verify warning messages for the 'Connet to database' page + public function testErrorsConnectToDatabasePage() { + parent::navigateConnetToDatabasePage(); + + // Verify warning mesage for invalid database host + $this->type( "mysql_wgDBserver", INVALID_DB_HOST ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (" . INVALID_DB_HOST . ").", + $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); + // Verify warning message for the blank database host + $this->type( "mysql_wgDBserver", "" ); + parent::clickContinueButton(); + $this->assertEquals( "MySQL 4.0.14 or later is required, you have .", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Valid Database Host + $this->type( "mysql_wgDBserver", VALID_DB_HOST ); + + // Verify warning message for the invalid database name + $this->type( "mysql_wgDBname", INVALID_DB_NAME ); + parent::clickContinueButton(); + $this->assertEquals( "Invalid database name \"" . INVALID_DB_NAME . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", + $this->getText( LINK_DIV . "div[2]/div[2]/p" ) ); + + // Verify warning message for the blank database name + $this->type( "mysql_wgDBname", "" ); + parent::clickContinueButton(); + $this->assertEquals( "You must enter a value for \"Database name\"", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // valid Database name + $this->type( "mysql_wgDBname", VALID_DB_NAME ); + + // Verify warning message for the invalid databaase prefix + $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX ); + parent::clickContinueButton(); + $this->assertEquals( "Invalid database prefix \"" . INVALID_DB_PREFIX . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Valid Database prefix + $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX ); + + // Verify warning message for the invalid database user name + $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: NO) (localhost).", + $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); + + // Verify warning message for the blank database user name + $this->type( "mysql__InstallUser", "" ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).", + $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); + + // Valid Database username + $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); + + // Verify warning message for the invalid password + $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); + parent::clickContinueButton(); + + $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).", + $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); + + // Verify warning message for the invalid username and password + $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); + $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); + parent::clickContinueButton(); + $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: YES) (localhost).", + $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); + $this->assertEquals( "Check the host, username and password below and try again.", + $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); + + // Valid username and valid password + $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); + $this->type( "mysql__InstallPassword", "" ); + parent::clickContinueButton(); + + // successfully completes the 'Connect to database' page + $this->assertEquals( "Database settings", + $this->getText( LINK_DIV . "h2" ) ); + } } diff --git a/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php b/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php index c2b35054d2..e3d42665b2 100644 --- a/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php +++ b/tests/selenium/installer/MediaWikiErrorsNamepageTestCase.php @@ -31,102 +31,94 @@ * Test Case ID : 10 (http://www.mediawiki.org/wiki/New_installer/Test_plan) * Test Case Name : Invalid/ blank values for fields in 'Name' page. * Version : MediaWiki 1.18alpha -*/ + */ require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' ); class MediaWikiErrorsNamepageTestCase extends MediaWikiInstallationCommonFunction { - - function setUp() { - parent::setUp(); - } - - // Verify warning message for the 'Name' page - public function testErrorsNamePage() { - - $databaseName = DB_NAME_PREFIX."_error_name"; - - parent::navigateNamePage( $databaseName ); - - // Verify warning message for all blank fields - parent::clickContinueButton(); - $this->assertEquals( "Enter a site name.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - $this->assertEquals( "Enter an administrator username.", - $this->getText( LINK_DIV."div[3]/div[2]" )); - $this->assertEquals( "Enter a password for the administrator account.", - $this->getText( LINK_DIV."div[4]/div[2]" )); - - // Verify warning message for the blank 'Site name' - $this->type( "config__AdminName", VALID_YOUR_NAME ); - $this->type( "config__AdminPassword", VALID_PASSWORD ); - $this->type( "config__AdminPassword2", VALID_PASSWORD_AGAIN ); - parent::clickContinueButton(); - $this->assertEquals( "Enter a site name.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - // Input valid 'Site name' - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - - - // Verify warning message for the invalid "Project namespace' - $this->click( "config__NamespaceType_other" ); - $this->type( "config_wgMetaNamespace", INVALID_NAMESPACE ); - parent::clickContinueButton(); - $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - - // Verify warning message for the blank 'Project namespace' - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - $this->click( "config__NamespaceType_other" ); - $this->type( "config_wgMetaNamespace" , "" ); - parent::clickContinueButton(); - $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - - // Valid 'Project namespace' - $this->click( "config__NamespaceType_other" ); - $this->type( "config_wgMetaNamespace", VALID_NAMESPACE ); - parent::clickContinueButton(); - - - // Valid 'Site name' - $this->click( "config__NamespaceType_site-name" ); - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - - - // Verify warning message for blank 'Your name' - $this->type( "config__AdminName", " " ); - parent::clickContinueButton(); - $this->assertEquals( "Enter an administrator username.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - // Verify warning message for blank 'Password' - $this->type( "config__AdminName", VALID_YOUR_NAME ); - $this->type( "config__AdminPassword", " " ); - parent::clickContinueButton(); - $this->assertEquals( "Enter a password for the administrator account.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - - // Verify warning message for the blank 'Password again' - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - $this->type( "config__AdminPassword", VALID_PASSWORD ); - $this->type( "config__AdminPassword2", " " ); - parent::clickContinueButton(); - $this->assertEquals( "The two passwords you entered do not match.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - - - // Verify warning message for the different'Password' and 'Password again' - $this->type( "config_wgSitename", VALID_WIKI_NAME ); - $this->type( "config__AdminPassword", VALID_PASSWORD ); - $this->type( "config__AdminPassword2", INVALID_PASSWORD_AGAIN ); - parent::clickContinueButton(); - $this->assertEquals( "The two passwords you entered do not match.", - $this->getText( LINK_DIV."div[2]/div[2]" )); - } + function setUp() { + parent::setUp(); + } + + // Verify warning message for the 'Name' page + public function testErrorsNamePage() { + + $databaseName = DB_NAME_PREFIX . "_error_name"; + + parent::navigateNamePage( $databaseName ); + + // Verify warning message for all blank fields + parent::clickContinueButton(); + $this->assertEquals( "Enter a site name.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + $this->assertEquals( "Enter an administrator username.", + $this->getText( LINK_DIV . "div[3]/div[2]" ) ); + $this->assertEquals( "Enter a password for the administrator account.", + $this->getText( LINK_DIV . "div[4]/div[2]" ) ); + + // Verify warning message for the blank 'Site name' + $this->type( "config__AdminName", VALID_YOUR_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", VALID_PASSWORD_AGAIN ); + parent::clickContinueButton(); + $this->assertEquals( "Enter a site name.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Input valid 'Site name' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + + // Verify warning message for the invalid "Project namespace' + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace", INVALID_NAMESPACE ); + parent::clickContinueButton(); + $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Verify warning message for the blank 'Project namespace' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace", "" ); + parent::clickContinueButton(); + $this->assertEquals( "The specified namespace \"\" is invalid. Specify a different project namespace.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Valid 'Project namespace' + $this->click( "config__NamespaceType_other" ); + $this->type( "config_wgMetaNamespace", VALID_NAMESPACE ); + parent::clickContinueButton(); + + // Valid 'Site name' + $this->click( "config__NamespaceType_site-name" ); + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + + // Verify warning message for blank 'Your name' + $this->type( "config__AdminName", " " ); + parent::clickContinueButton(); + $this->assertEquals( "Enter an administrator username.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + // Verify warning message for blank 'Password' + $this->type( "config__AdminName", VALID_YOUR_NAME ); + $this->type( "config__AdminPassword", " " ); + parent::clickContinueButton(); + $this->assertEquals( "Enter a password for the administrator account.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Verify warning message for the blank 'Password again' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", " " ); + parent::clickContinueButton(); + $this->assertEquals( "The two passwords you entered do not match.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + + // Verify warning message for the different'Password' and 'Password again' + $this->type( "config_wgSitename", VALID_WIKI_NAME ); + $this->type( "config__AdminPassword", VALID_PASSWORD ); + $this->type( "config__AdminPassword2", INVALID_PASSWORD_AGAIN ); + parent::clickContinueButton(); + $this->assertEquals( "The two passwords you entered do not match.", + $this->getText( LINK_DIV . "div[2]/div[2]" ) ); + } } diff --git a/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php b/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php index 78205cf84a..961f6920a9 100644 --- a/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php +++ b/tests/selenium/installer/MediaWikiHelpFieldHintTestCase.php @@ -31,110 +31,103 @@ * Test Case ID : 29 (http://www.mediawiki.org/wiki/New_installer/Test_plan) * Test Case Name : Help field hint availability for the fields. * Version : MediaWiki 1.18alpha -*/ + */ require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' ); class MediaWikiHelpFieldHintTestCase extends MediaWikiInstallationCommonFunction { - - function setUp() { - parent::setUp(); - } - - - // Verify help field availability for the fields - public function testMySQLConnectToDatabaseFieldHint() { - - parent::navigateConnetToDatabasePage(); - - // Verify help field for 'Database host' - $this->click( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[1]" ); - $this->assertEquals( MYSQL_DATABASE_HOST_HELP, - $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[2]" ) ); - - // Verify help field for 'Database name' - $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[1]" ); - $this->assertEquals( MYSQL_DATABASE_NAME_HELP, - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]" )); - - - // Verify help field for 'Database table prefix' - $this->click("//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/div/span[1]" ); - $this->assertEquals(MYSQL_DATABASE_TABLE_PREFIX_HELP, - $this->getText("//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]/p[1]" )); - - // Verify help field for 'Database username' - $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[1]" ); - $this->assertEquals( MYSQL_DATBASE_USERNAME_HELP, - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[2]" )); - - // Verify help field for 'Database password' - $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[1]" ); - $this->assertEquals( MYSQL_DATABASE_PASSWORD_HELP, - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[2]/p" )); - } - - - public function testSQLiteConnectToDatabaseFieldHint() { - - parent::navigateConnetToDatabasePage(); - $this->click( "DBType_sqlite" ); - - // Verify help field for 'SQLite data directory' - $this->click( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[1]" ); - $this->assertEquals( SQLITE_DATA_DIRECTORY_HELP, - $this->getText( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[2]" )); - - // Verify help field for 'Database name' - $this->click( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[1]" ); - $this->assertEquals( SQLITE_DATABASE_NAME_HELP , $this->getText( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[2]/p" )); - } - - - public function testDatabaseSettingsFieldHint() { - - $databaseName = DB_NAME_PREFIX."_db_field"; - parent::navigateDatabaseSettingsPage($databaseName); - - // Verify help field for 'Search engine' - $this->click( LINK_FORM."div[2]/span[1]" ); - $this->assertEquals( SEARCH_ENGINE_HELP, - $this->getText( LINK_FORM."div[2]/span[2]" )); - - // Verify help field for 'Database character set' - $this->click( LINK_FORM."div[4]/span[1]" ); - $this->assertEquals( DATABASE_CHARACTER_SET_HELP, - $this->getText( LINK_FORM."div[4]/span[2]")); - parent::restartInstallation(); - } - - - public function testNameFieldHint() { - - $databaseName = DB_NAME_PREFIX."_name_field"; - parent::navigateNamePage( $databaseName ); - - // Verify help field for 'Name of Wiki' - $this->click( LINK_FORM."div[1]/div[1]/div/span[1]" ); - $this->assertEquals( NAME_OF_WIKI_HELP, - $this->getText( LINK_FORM."div[1]/div[1]/div/span[2]/p" )); - - // Verify help field for 'Project namespace' - $this->click( LINK_FORM."div[2]/div[1]/div/span[1]" ); - $this->assertEquals( PROJECT_NAMESPACE_HELP, - $this->getText( LINK_FORM."div[2]/div[1]/div/span[2]/p")); - - // Verify help field for 'Your Name' - $this->click( LINK_FORM."fieldset/div[1]/div[1]/div/span[1]" ); - $this->assertEquals( USER_NAME_HELP, - $this->getText( LINK_FORM."fieldset/div[1]/div[1]/div/span[2]/p" )); - - // Verify help field for 'E mail address' - $this->click( LINK_FORM."fieldset/div[4]/div[1]/div/span[1]" ); - $this->assertEquals( EMAIL_ADDRESS_HELP, - $this->getText( LINK_FORM."fieldset/div[4]/div[1]/div/span[2]/p" )); - - parent::restartInstallation(); - } + function setUp() { + parent::setUp(); + } + + // Verify help field availability for the fields + public function testMySQLConnectToDatabaseFieldHint() { + + parent::navigateConnetToDatabasePage(); + + // Verify help field for 'Database host' + $this->click( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_HOST_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/div/span[2]" ) ); + + // Verify help field for 'Database name' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_NAME_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]" ) ); + + + // Verify help field for 'Database table prefix' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_TABLE_PREFIX_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/div/span[2]/p[1]" ) ); + + // Verify help field for 'Database username' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATBASE_USERNAME_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/div/span[2]" ) ); + + // Verify help field for 'Database password' + $this->click( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[1]" ); + $this->assertEquals( MYSQL_DATABASE_PASSWORD_HELP, + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/div/span[2]/p" ) ); + } + + public function testSQLiteConnectToDatabaseFieldHint() { + parent::navigateConnetToDatabasePage(); + $this->click( "DBType_sqlite" ); + + // Verify help field for 'SQLite data directory' + $this->click( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( SQLITE_DATA_DIRECTORY_HELP, + $this->getText( "//div[@id='DB_wrapper_sqlite']/div[1]/div[1]/div/span[2]" ) ); + + // Verify help field for 'Database name' + $this->click( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[1]" ); + $this->assertEquals( SQLITE_DATABASE_NAME_HELP, $this->getText( "//div[@id='DB_wrapper_sqlite']/div[2]/div[1]/div/span[2]/p" ) ); + } + + public function testDatabaseSettingsFieldHint() { + + $databaseName = DB_NAME_PREFIX . "_db_field"; + parent::navigateDatabaseSettingsPage( $databaseName ); + + // Verify help field for 'Search engine' + $this->click( LINK_FORM . "div[2]/span[1]" ); + $this->assertEquals( SEARCH_ENGINE_HELP, + $this->getText( LINK_FORM . "div[2]/span[2]" ) ); + + // Verify help field for 'Database character set' + $this->click( LINK_FORM . "div[4]/span[1]" ); + $this->assertEquals( DATABASE_CHARACTER_SET_HELP, + $this->getText( LINK_FORM . "div[4]/span[2]" ) ); + parent::restartInstallation(); + } + + public function testNameFieldHint() { + $databaseName = DB_NAME_PREFIX . "_name_field"; + parent::navigateNamePage( $databaseName ); + + // Verify help field for 'Name of Wiki' + $this->click( LINK_FORM . "div[1]/div[1]/div/span[1]" ); + $this->assertEquals( NAME_OF_WIKI_HELP, + $this->getText( LINK_FORM . "div[1]/div[1]/div/span[2]/p" ) ); + + // Verify help field for 'Project namespace' + $this->click( LINK_FORM . "div[2]/div[1]/div/span[1]" ); + $this->assertEquals( PROJECT_NAMESPACE_HELP, + $this->getText( LINK_FORM . "div[2]/div[1]/div/span[2]/p" ) ); + + // Verify help field for 'Your Name' + $this->click( LINK_FORM . "fieldset/div[1]/div[1]/div/span[1]" ); + $this->assertEquals( USER_NAME_HELP, + $this->getText( LINK_FORM . "fieldset/div[1]/div[1]/div/span[2]/p" ) ); + + // Verify help field for 'E mail address' + $this->click( LINK_FORM . "fieldset/div[4]/div[1]/div/span[1]" ); + $this->assertEquals( EMAIL_ADDRESS_HELP, + $this->getText( LINK_FORM . "fieldset/div[4]/div[1]/div/span[2]/p" ) ); + + parent::restartInstallation(); + } } diff --git a/tests/selenium/installer/MediaWikiInstallationCommonFunction.php b/tests/selenium/installer/MediaWikiInstallationCommonFunction.php index 353fa2ee63..06bad3099a 100644 --- a/tests/selenium/installer/MediaWikiInstallationCommonFunction.php +++ b/tests/selenium/installer/MediaWikiInstallationCommonFunction.php @@ -29,255 +29,234 @@ require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; require_once ( __DIR__ . '/MediaWikiInstallationConfig.php' ); require_once ( __DIR__ . '/MediaWikiInstallationMessage.php' ); -require_once ( __DIR__ . '/MediaWikiInstallationVariables.php'); - +require_once ( __DIR__ . '/MediaWikiInstallationVariables.php' ); class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase { - - function setUp() { - $this->setBrowser( TEST_BROWSER ); - $this->setBrowserUrl("http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/"); - } - - - public function navigateInitialpage() { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/" ); - } - - - // Navigate to the 'Language' page - public function navigateLanguagePage() { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - } - - - // Navigate to the 'Welcome to MediaWiki' page - public function navigateWelcometoMediaWikiPage() { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - $this->click( "submit-continue "); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate yo 'Connect to Database' page - public function navigateConnetToDatabasePage() { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click("submit-continue"); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate to the 'Database Settings' page - public function navigateDatabaseSettingsPage( $databaseName ) { - - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click("submit-continue"); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click("submit-continue"); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - $this->type("mysql_wgDBname", $databaseName ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate to the 'Name' page - public function navigateNamePage( $databaseName ) { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - $this->type( "mysql_wgDBname", $databaseName ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Database settings - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate 'Options' page - public function navigateOptionsPage( $databaseName ) { - - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - $this->type( "mysql_wgDBname", $databaseName ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Database settings - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Name - $this->type( "config_wgSitename", NAME_OF_WIKI ); - $this->type( "config__AdminName", ADMIN_USER_NAME); - $this->type( "config__AdminPassword", ADMIN_PASSWORD ); - $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); - $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); - - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate 'Install' page - public function navigateInstallPage( $databaseName ) { - - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - $this->type( "mysql_wgDBname", $databaseName ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Database settings - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Name - $this->type( "config_wgSitename", NAME_OF_WIKI ); - $this->type( "config__AdminName", ADMIN_USER_NAME); - $this->type( "config__AdminPassword", ADMIN_PASSWORD ); - $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); - $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); - - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Options page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Navigate to 'Complete' page - public function navigateCompletePage( $databaseName ) { - $this->open( "http://".HOST_NAME.":".PORT."/".DIRECTORY_NAME."/config/index.php" ); - - // 'Welcome to MediaWiki!' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Connect to Database' page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - $this->type( "mysql_wgDBname", $databaseName ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Database settings - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Name - $this->type( "config_wgSitename", NAME_OF_WIKI ); - $this->type( "config__AdminName", ADMIN_USER_NAME); - $this->type( "config__AdminPassword", ADMIN_PASSWORD ); - $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); - $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); - - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Options page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Install page - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - $this->chooseCancelOnNextConfirmation(); - } - - - // Complete the Name page fields - public function completeNamePage() { - $this->type( "config_wgSitename", NAME_OF_WIKI ); - $this->type( "config__AdminName", ADMIN_USER_NAME); - $this->type( "config__AdminPassword", ADMIN_PASSWORD ); - $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); - $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME); - } - - - // Clicking on the 'Continue' button in any MediaWiki page - public function clickContinueButton() { - $this->click( "submit-continue" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Clicking on the 'Back' button in any MediaWiki page - public function clickBackButton() { - $this->click( "submit-back" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Restarting the installation - public function restartInstallation() { - $this->click( "link=Restart installation" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - $this->click( "submit-restart" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - } - - - // Verify 'MediaWiki' logo available in the initial screen - public function mediaWikiLogoPresentInitialScreen() { - $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" )); - } - - - // Verify 'MediaWiki' logo available - public function mediaWikiLogoPresent() { - $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" )); - } - - - public function completePageSuccessfull() { - $this->assertEquals( "Complete!", - $this->getText( "//div[@id='bodyContent']/div/div/h2" )); - - // 'Congratulations!' text should be available in the 'Complete!' page. - $this->assertEquals( "Congratulations!", - $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" )); - } + function setUp() { + $this->setBrowser( TEST_BROWSER ); + $this->setBrowserUrl( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" ); + } + + public function navigateInitialpage() { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" ); + } + + // Navigate to the 'Language' page + public function navigateLanguagePage() { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + } + + // Navigate to the 'Welcome to MediaWiki' page + public function navigateWelcometoMediaWikiPage() { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + $this->click( "submit-continue " ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate yo 'Connect to Database' page + public function navigateConnetToDatabasePage() { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate to the 'Database Settings' page + public function navigateDatabaseSettingsPage( $databaseName ) { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate to the 'Name' page + public function navigateNamePage( $databaseName ) { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate 'Options' page + public function navigateOptionsPage( $databaseName ) { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME ); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate 'Install' page + public function navigateInstallPage( $databaseName ) { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME ); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Options page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Navigate to 'Complete' page + public function navigateCompletePage( $databaseName ) { + $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + + // 'Welcome to MediaWiki!' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Connect to Database' page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + $this->type( "mysql_wgDBname", $databaseName ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Database settings + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Name + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME ); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Options page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Install page + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->chooseCancelOnNextConfirmation(); + } + + // Complete the Name page fields + public function completeNamePage() { + $this->type( "config_wgSitename", NAME_OF_WIKI ); + $this->type( "config__AdminName", ADMIN_USER_NAME ); + $this->type( "config__AdminPassword", ADMIN_PASSWORD ); + $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD ); + $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS ); + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Clicking on the 'Continue' button in any MediaWiki page + public function clickContinueButton() { + $this->click( "submit-continue" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Clicking on the 'Back' button in any MediaWiki page + public function clickBackButton() { + $this->click( "submit-back" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Restarting the installation + public function restartInstallation() { + $this->click( "link=Restart installation" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->click( "submit-restart" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + } + + // Verify 'MediaWiki' logo available in the initial screen + public function mediaWikiLogoPresentInitialScreen() { + $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) ); + } + + // Verify 'MediaWiki' logo available + public function mediaWikiLogoPresent() { + $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ) ); + } + + public function completePageSuccessfull() { + $this->assertEquals( "Complete!", + $this->getText( "//div[@id='bodyContent']/div/div/h2" ) ); + + // 'Congratulations!' text should be available in the 'Complete!' page. + $this->assertEquals( "Congratulations!", + $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" ) ); + } } diff --git a/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php b/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php index 5cdc8d42c1..c20fafe158 100644 --- a/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php +++ b/tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php @@ -28,90 +28,90 @@ */ -require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php'); +require_once ( __DIR__ . '/' . 'MediaWikiInstallationCommonFunction.php' ); /** * Test Case ID : 05 (http://www.mediawiki.org/wiki/New_installer/Test_plan) * Test Case Name : Install Mediawiki by updating the existing database. * Version : MediaWiki 1.18alpha -*/ - + */ class MediaWikiUpgradeExistingDatabaseTestCase extends MediaWikiInstallationCommonFunction { - - function setUp() { - parent::setUp(); - } - - // Install Mediawiki using 'MySQL' database type. - public function testUpgradeExistingDatabase() { - - $databaseName = DB_NAME_PREFIX."_upgrade_existing"; - parent::navigateInstallPage( $databaseName ); - - $this->open( "http://localhost:".PORT."/".DIRECTORY_NAME."/config/index.php" ); - $this->assertEquals( "Install", $this->getText( LINK_DIV."h2" )); - $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", - $this->getText( LINK_DIV."div[2]/form/div[1]/div[2]" )); - - // 'Optionis' page - parent::clickBackButton(); - - // 'Name' page - parent::clickBackButton(); - - // 'Database settings' page - parent::clickBackButton(); - - // 'Connect to database' page - parent::clickBackButton(); - $this->type( "mysql_wgDBname", $databaseName ); - parent::clickContinueButton(); - - // 'Upgrade existing installation' page displayed next to the 'Connect to database' page. - $this->assertEquals( "Upgrade existing installation", $this->getText( LINK_DIV."h2" )); - - // Warning message displayed. - $this->assertEquals( "There are MediaWiki tables in this database. To upgrade them to MediaWiki 1.18alpha, click Continue.", - $this->getText( LINK_DIV."div[2]/form/div[1]/div[2]" )); - - parent::clickContinueButton(); - $this->assertEquals( "Upgrade existing installation", - $this->getText( LINK_DIV."h2" )); - - // 'Upgrade complete.' text display - $this->assertEquals("Upgrade complete.", - $this->getText("//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[1]")); - - $this->assertEquals("You can now Folder/index.php start using your wiki.", - $this->getText("//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[2]" )); - - $this->assertEquals( "Folder/index.php start using your wiki", - $this->getText( "link=Folder/index.php start using your wiki" )); - - $this->assertTrue($this->isElementPresent( "submit-regenerate" )); - $this->click( "submit-regenerate" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - $this->assertEquals( "Database settings", - $this->getText( LINK_DIV."h2" )); - - // 'Database settings' page - parent::clickContinueButton(); - - // Name page - parent::completeNamePage(); - - // Options page - parent::clickContinueButton(); - - // Install page - $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", - $this->getText( LINK_FORM."div[1]/div[2]" )); - parent::clickContinueButton(); - - // complete - parent::completePageSuccessfull(); - $this->chooseCancelOnNextConfirmation(); - parent::restartInstallation(); - } + function setUp() { + parent::setUp(); + } + + // Install Mediawiki using 'MySQL' database type. + public function testUpgradeExistingDatabase() { + + $databaseName = DB_NAME_PREFIX . "_upgrade_existing"; + parent::navigateInstallPage( $databaseName ); + + $this->open( "http://localhost:" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" ); + $this->assertEquals( "Install", $this->getText( LINK_DIV . "h2" ) ); + $this->assertEquals( + "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_DIV . "div[2]/form/div[1]/div[2]" ) + ); + + // 'Optionis' page + parent::clickBackButton(); + + // 'Name' page + parent::clickBackButton(); + + // 'Database settings' page + parent::clickBackButton(); + + // 'Connect to database' page + parent::clickBackButton(); + $this->type( "mysql_wgDBname", $databaseName ); + parent::clickContinueButton(); + + // 'Upgrade existing installation' page displayed next to the 'Connect to database' page. + $this->assertEquals( "Upgrade existing installation", $this->getText( LINK_DIV . "h2" ) ); + + // Warning message displayed. + $this->assertEquals( "There are MediaWiki tables in this database. To upgrade them to MediaWiki 1.18alpha, click Continue.", + $this->getText( LINK_DIV . "div[2]/form/div[1]/div[2]" ) ); + + parent::clickContinueButton(); + $this->assertEquals( "Upgrade existing installation", + $this->getText( LINK_DIV . "h2" ) ); + + // 'Upgrade complete.' text display + $this->assertEquals( "Upgrade complete.", + $this->getText( "//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[1]" ) ); + + $this->assertEquals( "You can now Folder/index.php start using your wiki.", + $this->getText( "//div[@id='bodyContent']/div/div[1]/div[4]/form/div[1]/div[2]/p[2]" ) ); + + $this->assertEquals( "Folder/index.php start using your wiki", + $this->getText( "link=Folder/index.php start using your wiki" ) ); + + $this->assertTrue( $this->isElementPresent( "submit-regenerate" ) ); + $this->click( "submit-regenerate" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + $this->assertEquals( "Database settings", + $this->getText( LINK_DIV . "h2" ) ); + + // 'Database settings' page + parent::clickContinueButton(); + + // Name page + parent::completeNamePage(); + + // Options page + parent::clickContinueButton(); + + // Install page + $this->assertEquals( "Warning: You seem to have already installed MediaWiki and are trying to install it again. Please proceed to the next page.", + $this->getText( LINK_FORM . "div[1]/div[2]" ) ); + parent::clickContinueButton(); + + // complete + parent::completePageSuccessfull(); + $this->chooseCancelOnNextConfirmation(); + parent::restartInstallation(); + } } diff --git a/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php b/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php index 15fad95fcf..c73effcd47 100644 --- a/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php +++ b/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php @@ -27,505 +27,474 @@ * */ -require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php'); +require_once ( __DIR__ . '/' . 'MediaWikiInstallationCommonFunction.php' ); /** * Test Case ID : 18 - 27 (http://www.mediawiki.org/wiki/New_installer/Test_plan) * Test Case Name : UI of MediaWiki initial/ Language/ Welcome to MediaWiki!/ Connect to database/ * Database settings/ Name/ Options/ Install/ Complete/ Restart Inslation pages * Version : MediaWiki 1.18alpha -*/ + */ class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction { - - function setUp() { - parent::setUp(); - } - - - public function testInitialPageUI() { - - parent::navigateInitialpage(); - - // MediaWiki logo available - $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" )); - - // 'MediaWiki 1.18alpha' text available - $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" )); - - // 'LocalSettings.php not found.' text available - $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" )); - - // 'Please set up the wiki first' text available - $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" )); - - // 'set up the wiki' link available - $this->assertTrue($this->isElementPresent( "link=set up the wiki" )); - } - - - public function testlanguagePageUI() { - - parent::navigateLanguagePage(); - - // Verify 'Language' heading - $this->assertEquals( "Language", $this->getText( LINK_DIV."h2" )); - - // 'Your language' label available - $this->assertEquals( "Your language:", - $this->getText( LINK_FORM."div[1]/div[1]/label" )); - - // 'Your language' dropdown available - $this->assertTrue( $this->isElementPresent( "UserLang" )); - - // 'Wiki language' label available - $this->assertEquals( "Wiki language:", - $this->getText( LINK_FORM."div[2]/div[1]/label" )); - - // 'Wiki language' dropdown available - $this->assertTrue($this->isElementPresent( "ContLang" )); - } - - - public function testWelcometoMediaWikiUI() { - - parent::navigateWelcometoMediaWikiPage(); - - // Verify 'Welcome to MediaWiki!' heading - $this->assertEquals( "Welcome to MediaWiki!", - $this->getText( LINK_DIV."h2" )); - - // Verify environment ok text displayed. - $this->assertEquals( "The environment has been checked.You can install MediaWiki.", - $this->getText( LINK_DIV."div[6]/span" )); - } - - - public function testConnectToDatabaseUI() { - - parent::navigateConnetToDatabasePage(); - - // 'MYSQL radio button available - $this->assertEquals( "MySQL", - $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" )); - $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[1]" )); - - // 'SQLite' radio button available - $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[2]" )); - $this->assertEquals( "SQLite", $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label ")); - - // 'Database host' label available - $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" )); - - // 'Database host' text box default to 'localhost' - $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" )); - - // 'Identify this wiki' section available - $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" )); - - // 'Identify this wiki' label available - $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" )); - - // 'Database name' lable available - $this->assertEquals( "Database name:", - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" )); - - // Verify 'Database name:' text box is default to 'my_wiki' - $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" )); - - // Verify 'Database table prefix:' label available - $this->assertEquals( "Database table prefix:", - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" )); - - // 'User account for installation' section available - $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" )); - - // 'User account for installation' label available - $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" )); - - // 'Database username' label available - $this->assertEquals( "Database username:", - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" )); - - // 'Database username' text box defaults to 'root' - $this->assertEquals("root", $this->getValue( "mysql__InstallUser" )); - - // 'Database password' label available - $this->assertEquals( "Database password:", - $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" )); - } - - - - public function testDatabaseSettingsUI() { - - $databaseName = DB_NAME_PREFIX."_db_settings_UI"; - parent::navigateDatabaseSettingsPage( $databaseName ); - - // 'Database settings' text available. - $this->assertEquals( "Database settings", $this->getText( LINK_DIV."h2" )); - - // 'Database account for web access' section available - $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" )); - - // 'Database account for web access' label available - $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM."fieldset/legend" )); - - // 'Use the same account as for installation' check box available - $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM."fieldset/div[1]/label" )); - - // 'Use the same account as for installation' check box is selected by default - $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" )); - - // 'Use the same account as for installation' check box deselected - $this->click( "mysql__SameAccount" ); - - // verify 'Use the same account as for installation' check box is not selected - $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" )); - - // 'Database username' label available - $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" )); - - // 'Database username' text box is default to the 'wikiuser' - $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" )); - - // 'Database password' label available - $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" )); - - // 'Create the account if it does not already exist' label available - $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" )); - - // 'Create the account if it does not already exist' check box is not selected by default - $this->assertEquals( "off" , $this->getValue( "mysql__CreateDBAccount" )); - - // 'Create the account if it does not already exist' check box selected - $this->click( "mysql__CreateDBAccount" ); - - // Verify 'Create the account if it does not already exist' check box is selected - $this->assertEquals( "on" , $this->getValue( "mysql__CreateDBAccount" )); - $this->click( "mysql__SameAccount" ); - $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" )); - - // 'Storage engine' label available - $this->assertEquals( "Storage engine:", - $this->getText( LINK_FORM."div[1]/div[1]/label")); - - // 'InnoDB' label available - $this->assertEquals( "InnoDB", - $this->getText( LINK_FORM."div[1]/div[2]/ul/li[1]/label" )); - - // 'InnoDB' radio button available - $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" )); - - // 'MyISAM' label available - $this->assertEquals( "MyISAM", $this->getText( LINK_FORM."div[1]/div[2]/ul/li[2]/label" )); - - // 'MyISAM' radio button available - $this->assertTrue($this->isElementPresent( "mysql__MysqlEngine_MyISAM" )); - - // 'Database character set' label available - $this->assertEquals( "Database character set:", - $this->getText( LINK_FORM."div[3]/div[1]/label" )); - - // 'Binary' radio button available - $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" )); - - // 'Binary' radio button available - $this->assertEquals( "Binary", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[1]/label" )); - - // 'UTF-8' radio button available - $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" )); - - // 'UTF-8' label available - $this->assertEquals( "UTF-8", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[2]/label" )); - - // 'Binary' radio button is selected - $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" )); - } - - - - public function testNamePageUI() { - - $databaseName = DB_NAME_PREFIX."_name_UI"; - parent::navigateNamePage($databaseName); - - // 'Name of wiki' text box available - $this->assertEquals( "Name of wiki:", - $this->getText( LINK_FORM."div[1]/div[1]/label" )); - - $this->assertTrue( $this->isElementPresent( "config_wgSitename" )); - - // 'Project namespace' label available - $this->assertEquals( "Project namespace:", - $this->getText( LINK_FORM."div[2]/div[1]/label" )); - - // 'Same as the wiki name' radio button available - $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" )); - - // 'Project' radio button available - $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" )); - - // 'Project' radio button available - $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" )); - - // 'Same as the wiki name' label available - $this->assertEquals( "Same as the wiki name:", - $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" )); - - // 'Project' label available - $this->assertEquals("Project", - $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label" )); - - // 'Project' label available - $this->assertEquals( "Other (specify)", - $this->getText( LINK_FORM."div[2]/div[2]/ul/li[3]/label" )); - - // 'Same as the wiki name' radio button selected by default - $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" )); - - // 'Administrator account' section available - $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" )); - - // 'Administrator account' label available - $this->assertEquals( "Administrator account", - $this->getText( LINK_FORM."fieldset/legend" )); - - // 'Your Name' label available - $this->assertEquals( "Your name:", - $this->getText( LINK_FORM."fieldset/div[1]/div[1]/label" )); - - // 'Your Name' text box available - $this->assertTrue( $this->isElementPresent( "config__AdminName" )); - - // 'Password' label available - $this->assertEquals( "Password:", - $this->getText( LINK_FORM."fieldset/div[2]/div[1]/label" )); - - // 'Password' text box available - $this->assertTrue( $this->isElementPresent( "config__AdminPassword" )); - - // 'Password again' label available - $this->assertEquals( "Password again:", - $this->getText( LINK_FORM."fieldset/div[3]/div[1]/label" )); - - // 'Password again' text box available - $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" )); - - // 'Email address' label avaialble - $this->assertEquals( "E-mail address:", - $this->getText( LINK_FORM."fieldset/div[4]/div[1]/label" )); - - // 'Email address' text box available - $this->assertTrue( $this->isElementPresent( "config__AdminEmail" )); - - // Message displayed - $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.", - $this->getText( LINK_FORM."/div[4]/div[2]/p" )); - - // 'Ask me more questions.' radio button available - $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" )); - - // 'Ask me more questions.' label available - $this->assertEquals( "Ask me more questions.", - $this->getText( LINK_FORM."div[5]/div[2]/ul/li[1]/label" )); - - // 'I'm bored already, just install the wiki' radio button is avaiable - $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" )); - - // 'I'm bored already, just install the wiki' label available - $this->assertEquals( "I'm bored already, just install the wiki.", - $this->getText( LINK_FORM."div[5]/div[2]/ul/li[2]/label" )); - - // 'Ask me more questions.' radio button is default selected - $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" )); - } - - - - public function testOptionPageUI() { - - $databaseName = DB_NAME_PREFIX."_options_UI"; - parent::navigateOptionsPage($databaseName); - - // 'Options' label available - $this->assertEquals( "Options", $this->getText( LINK_DIV."h2")); - - // 'Return e-mail address' label available - $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" )); - - // 'Return e-mail address' text box available - $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" )); - - // Text 'apache@localhost' is default value of the 'Return e-mail address' text box - $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" )); - - // 'Logo URL' label available - $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM."fieldset[2]/div[3]/div[1]/label" )); - - // 'Logo URL' text box available - $this->assertTrue( $this->isElementPresent( "config_wgLogo" )); - - // Correct path available in the 'Logo URL' text box - $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" )); - - // 'Enable file uploads' radio button available - $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" )); - - // 'Enable file uploads' label available - $this->assertEquals( "Enable file uploads", - $this->getText( LINK_FORM."fieldset[2]/div[1]/label" )); - - // 'Enable file uploads' check box is not selected - $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" )); - - $this->click( "config_wgEnableUploads" ); - - // 'Directory for deleted files' label available - $this->assertEquals( "Directory for deleted files:", - $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" )); - - // 'Directory for deleted files' text box available - $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" )); - - // Correct path available in the 'Directory for deleted files' text box - $this->assertEquals( "C:\\wamp\\www\\".DIRECTORY_NAME."/images/deleted", - $this->getValue( "config_wgDeletedDirectory" )); - } - - - - public function testInstallPageUI() { - - $databaseName = DB_NAME_PREFIX."_install_UI"; - parent::navigateInstallPage( $databaseName ); - - // Verify installation done messages display - $this->assertEquals( "Setting up database... done", - $this->getText( LINK_FORM."ul/li[1]" )); - $this->assertEquals( "Creating tables... done", - $this->getText( LINK_FORM."ul/li[2]" )); - $this->assertEquals( "Creating database user... done", - $this->getText( LINK_FORM."ul/li[3]" )); - $this->assertEquals( "Populating default interwiki table... done", - $this->getText( LINK_FORM."ul/li[4]" )); - $this->assertEquals( "Generating secret key... done", - $this->getText( LINK_FORM."ul/li[5]" )); - $this->assertEquals( "Generating default upgrade key... done", - $this->getText( LINK_FORM."ul/li[6]" )); - $this->assertEquals( "Creating administrator user account... done", - $this->getText( LINK_FORM."ul/li[7]" )); - $this->assertEquals( "Creating main page with default content... done", - $this->getText( LINK_FORM."ul/li[8]" )); - } - - - - public function testCompletePageUI() { - - $databaseName = DB_NAME_PREFIX."_complete_UI"; - parent::navigateCompletePage( $databaseName ); - - // 'Congratulations!' text display - $this->assertEquals("Congratulations!", - $this->getText( LINK_FORM."div[1]/div[2]/p[1]/b")); - // 'LocalSettings.php' generated message display - $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.", - $this->getText( LINK_FORM."div[1]/div[2]/p[2]" )); - - // 'Download LocalSettings.php'' link available - $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" )); - - // 'enter your wiki' link available - $this->assertTrue($this->isElementPresent("link=Folder/index.php enter your wiki")); - } - - - - public function testRestartInstallation() { - - parent::navigateConnetToDatabasePage(); - $this->click( "link=Restart installation" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // Restart installation' label should be available. - $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2" )); - - //'Do you want to clear all saved data that you have entered and restart the installation process?' label available - $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?", - $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" )); - // 'Back' button available - $this->assertTrue($this->isElementPresent( "submit-back" )); - - // 'Restart' button available - $this->assertTrue($this->isElementPresent( "submit-restart" )); - } - - - - public function testMediaWikiLogoAvailability() { - - $databaseName = DB_NAME_PREFIX."_mediawiki_logo"; - parent::navigateInitialpage(); - parent::mediaWikiLogoPresentInitialScreen(); - $this->click( "link=set up the wiki" ); - $this->waitForPageToLoad( PAGE_LOAD_TIME ); - - // 'Language' page - parent::mediaWikiLogoPresent(); - parent::clickContinueButton(); - - // 'Welcome to MediaWiki' page - parent::mediaWikiLogoPresent(); - parent::clickContinueButton(); - - // 'Connet to database' page - parent::mediaWikiLogoPresent(); - $this->type("mysql_wgDBname", $databaseName ); - parent::clickContinueButton(); - - // 'Database setting' page - parent::mediaWikiLogoPresent(); - parent::clickContinueButton(); - - // 'Name' page - parent::mediaWikiLogoPresent(); - parent::completeNamePage(); - parent::clickContinueButton(); - - // 'Options' page - parent::mediaWikiLogoPresent(); - parent::clickContinueButton(); - - // 'Install' page - parent::mediaWikiLogoPresent(); - } - - - public function testRightFramework() { - - parent::navigateLanguagePage(); - // Verfy right framework texts display - $this->assertEquals( "Language", - $this->getText( LINK_RIGHT_FRAMEWORK."li[1]" )); - $this->assertEquals( "Existing wiki", - $this->getText( LINK_RIGHT_FRAMEWORK."li[2]" )); - $this->assertEquals( "Welcome to MediaWiki!", - $this->getText( LINK_RIGHT_FRAMEWORK."li[3]" )); - $this->assertEquals( "Connect to database", - $this->getText( LINK_RIGHT_FRAMEWORK."li[4]" )); - $this->assertEquals( "Upgrade existing installation", - $this->getText( LINK_RIGHT_FRAMEWORK."li[5]" )); - $this->assertEquals( "Database settings", - $this->getText( LINK_RIGHT_FRAMEWORK."li[6]" )); - $this->assertEquals( "Name", - $this->getText( LINK_RIGHT_FRAMEWORK."li[7]" )); - $this->assertEquals( "Options", - $this->getText( LINK_RIGHT_FRAMEWORK."li[8]" )); - $this->assertEquals( "Install", - $this->getText( LINK_RIGHT_FRAMEWORK."li[9]" )); - $this->assertEquals( "Complete!", - $this->getText( LINK_RIGHT_FRAMEWORK."li[10]/span" )); - } + function setUp() { + parent::setUp(); + } + + public function testInitialPageUI() { + + parent::navigateInitialpage(); + + // MediaWiki logo available + $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) ); + + // 'MediaWiki 1.18alpha' text available + $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" ) ); + + // 'LocalSettings.php not found.' text available + $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" ) ); + + // 'Please set up the wiki first' text available + $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" ) ); + + // 'set up the wiki' link available + $this->assertTrue( $this->isElementPresent( "link=set up the wiki" ) ); + } + + public function testlanguagePageUI() { + parent::navigateLanguagePage(); + + // Verify 'Language' heading + $this->assertEquals( "Language", $this->getText( LINK_DIV . "h2" ) ); + + // 'Your language' label available + $this->assertEquals( "Your language:", + $this->getText( LINK_FORM . "div[1]/div[1]/label" ) ); + + // 'Your language' dropdown available + $this->assertTrue( $this->isElementPresent( "UserLang" ) ); + + // 'Wiki language' label available + $this->assertEquals( "Wiki language:", + $this->getText( LINK_FORM . "div[2]/div[1]/label" ) ); + + // 'Wiki language' dropdown available + $this->assertTrue( $this->isElementPresent( "ContLang" ) ); + } + + public function testWelcometoMediaWikiUI() { + parent::navigateWelcometoMediaWikiPage(); + + // Verify 'Welcome to MediaWiki!' heading + $this->assertEquals( "Welcome to MediaWiki!", + $this->getText( LINK_DIV . "h2" ) ); + + // Verify environment ok text displayed. + $this->assertEquals( "The environment has been checked.You can install MediaWiki.", + $this->getText( LINK_DIV . "div[6]/span" ) ); + } + + public function testConnectToDatabaseUI() { + parent::navigateConnetToDatabasePage(); + + // 'MYSQL radio button available + $this->assertEquals( "MySQL", + $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[1]/label" ) ); + $this->assertTrue( $this->isElementPresent( LINK_FORM . "div[2]/div[2]/ul/li[1]" ) ); + + // 'SQLite' radio button available + $this->assertTrue( $this->isElementPresent( LINK_FORM . "div[2]/div[2]/ul/li[2]" ) ); + $this->assertEquals( "SQLite", $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[2]/label " ) ); + + // 'Database host' label available + $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" ) ); + + // 'Database host' text box default to 'localhost' + $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" ) ); + + // 'Identify this wiki' section available + $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) ); + + // 'Identify this wiki' label available + $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ) ); + + // 'Database name' lable available + $this->assertEquals( "Database name:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" ) ); + + // Verify 'Database name:' text box is default to 'my_wiki' + $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" ) ); + + // Verify 'Database table prefix:' label available + $this->assertEquals( "Database table prefix:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" ) ); + + // 'User account for installation' section available + $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) ); + + // 'User account for installation' label available + $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ) ); + + // 'Database username' label available + $this->assertEquals( "Database username:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" ) ); + + // 'Database username' text box defaults to 'root' + $this->assertEquals( "root", $this->getValue( "mysql__InstallUser" ) ); + + // 'Database password' label available + $this->assertEquals( "Database password:", + $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" ) ); + } + + public function testDatabaseSettingsUI() { + $databaseName = DB_NAME_PREFIX . "_db_settings_UI"; + parent::navigateDatabaseSettingsPage( $databaseName ); + + // 'Database settings' text available. + $this->assertEquals( "Database settings", $this->getText( LINK_DIV . "h2" ) ); + + // 'Database account for web access' section available + $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) ); + + // 'Database account for web access' label available + $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM . "fieldset/legend" ) ); + + // 'Use the same account as for installation' check box available + $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM . "fieldset/div[1]/label" ) ); + + // 'Use the same account as for installation' check box is selected by default + $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ) ); + + // 'Use the same account as for installation' check box deselected + $this->click( "mysql__SameAccount" ); + + // verify 'Use the same account as for installation' check box is not selected + $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" ) ); + + // 'Database username' label available + $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" ) ); + + // 'Database username' text box is default to the 'wikiuser' + $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" ) ); + + // 'Database password' label available + $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" ) ); + + // 'Create the account if it does not already exist' label available + $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" ) ); + + // 'Create the account if it does not already exist' check box is not selected by default + $this->assertEquals( "off", $this->getValue( "mysql__CreateDBAccount" ) ); + + // 'Create the account if it does not already exist' check box selected + $this->click( "mysql__CreateDBAccount" ); + + // Verify 'Create the account if it does not already exist' check box is selected + $this->assertEquals( "on", $this->getValue( "mysql__CreateDBAccount" ) ); + $this->click( "mysql__SameAccount" ); + $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ) ); + + // 'Storage engine' label available + $this->assertEquals( "Storage engine:", + $this->getText( LINK_FORM . "div[1]/div[1]/label" ) ); + + // 'InnoDB' label available + $this->assertEquals( "InnoDB", + $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[1]/label" ) ); + + // 'InnoDB' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" ) ); + + // 'MyISAM' label available + $this->assertEquals( "MyISAM", $this->getText( LINK_FORM . "div[1]/div[2]/ul/li[2]/label" ) ); + + // 'MyISAM' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_MyISAM" ) ); + + // 'Database character set' label available + $this->assertEquals( "Database character set:", + $this->getText( LINK_FORM . "div[3]/div[1]/label" ) ); + + // 'Binary' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" ) ); + + // 'Binary' radio button available + $this->assertEquals( "Binary", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[1]/label" ) ); + + // 'UTF-8' radio button available + $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" ) ); + + // 'UTF-8' label available + $this->assertEquals( "UTF-8", $this->getText( LINK_FORM . "div[3]/div[2]/ul/li[2]/label" ) ); + + // 'Binary' radio button is selected + $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" ) ); + } + + public function testNamePageUI() { + $databaseName = DB_NAME_PREFIX . "_name_UI"; + parent::navigateNamePage( $databaseName ); + + // 'Name of wiki' text box available + $this->assertEquals( "Name of wiki:", + $this->getText( LINK_FORM . "div[1]/div[1]/label" ) ); + + $this->assertTrue( $this->isElementPresent( "config_wgSitename" ) ); + + // 'Project namespace' label available + $this->assertEquals( "Project namespace:", + $this->getText( LINK_FORM . "div[2]/div[1]/label" ) ); + + // 'Same as the wiki name' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" ) ); + + // 'Project' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" ) ); + + // 'Project' radio button available + $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" ) ); + + // 'Same as the wiki name' label available + $this->assertEquals( "Same as the wiki name:", + $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[1]/label" ) ); + + // 'Project' label available + $this->assertEquals( "Project", + $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[2]/label" ) ); + + // 'Project' label available + $this->assertEquals( "Other (specify)", + $this->getText( LINK_FORM . "div[2]/div[2]/ul/li[3]/label" ) ); + + // 'Same as the wiki name' radio button selected by default + $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" ) ); + + // 'Administrator account' section available + $this->assertTrue( $this->isElementPresent( LINK_FORM . "fieldset" ) ); + + // 'Administrator account' label available + $this->assertEquals( "Administrator account", + $this->getText( LINK_FORM . "fieldset/legend" ) ); + + // 'Your Name' label available + $this->assertEquals( "Your name:", + $this->getText( LINK_FORM . "fieldset/div[1]/div[1]/label" ) ); + + // 'Your Name' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminName" ) ); + + // 'Password' label available + $this->assertEquals( "Password:", + $this->getText( LINK_FORM . "fieldset/div[2]/div[1]/label" ) ); + + // 'Password' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminPassword" ) ); + + // 'Password again' label available + $this->assertEquals( "Password again:", + $this->getText( LINK_FORM . "fieldset/div[3]/div[1]/label" ) ); + + // 'Password again' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" ) ); + + // 'Email address' label avaialble + $this->assertEquals( "E-mail address:", + $this->getText( LINK_FORM . "fieldset/div[4]/div[1]/label" ) ); + + // 'Email address' text box available + $this->assertTrue( $this->isElementPresent( "config__AdminEmail" ) ); + + // Message displayed + $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.", + $this->getText( LINK_FORM . "/div[4]/div[2]/p" ) ); + + // 'Ask me more questions.' radio button available + $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" ) ); + + // 'Ask me more questions.' label available + $this->assertEquals( "Ask me more questions.", + $this->getText( LINK_FORM . "div[5]/div[2]/ul/li[1]/label" ) ); + + // 'I'm bored already, just install the wiki' radio button is avaiable + $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" ) ); + + // 'I'm bored already, just install the wiki' label available + $this->assertEquals( "I'm bored already, just install the wiki.", + $this->getText( LINK_FORM . "div[5]/div[2]/ul/li[2]/label" ) ); + + // 'Ask me more questions.' radio button is default selected + $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" ) ); + } + + public function testOptionPageUI() { + $databaseName = DB_NAME_PREFIX . "_options_UI"; + parent::navigateOptionsPage( $databaseName ); + + // 'Options' label available + $this->assertEquals( "Options", $this->getText( LINK_DIV . "h2" ) ); + + // 'Return e-mail address' label available + $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" ) ); + + // 'Return e-mail address' text box available + $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" ) ); + + // Text 'apache@localhost' is default value of the 'Return e-mail address' text box + $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" ) ); + + // 'Logo URL' label available + $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM . "fieldset[2]/div[3]/div[1]/label" ) ); + + // 'Logo URL' text box available + $this->assertTrue( $this->isElementPresent( "config_wgLogo" ) ); + + // Correct path available in the 'Logo URL' text box + $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" ) ); + + // 'Enable file uploads' radio button available + $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" ) ); + + // 'Enable file uploads' label available + $this->assertEquals( "Enable file uploads", + $this->getText( LINK_FORM . "fieldset[2]/div[1]/label" ) ); + + // 'Enable file uploads' check box is not selected + $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" ) ); + + $this->click( "config_wgEnableUploads" ); + + // 'Directory for deleted files' label available + $this->assertEquals( "Directory for deleted files:", + $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" ) ); + + // 'Directory for deleted files' text box available + $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" ) ); + + // Correct path available in the 'Directory for deleted files' text box + $this->assertEquals( "C:\\wamp\\www\\" . DIRECTORY_NAME . "/images/deleted", + $this->getValue( "config_wgDeletedDirectory" ) ); + } + + public function testInstallPageUI() { + $databaseName = DB_NAME_PREFIX . "_install_UI"; + parent::navigateInstallPage( $databaseName ); + + // Verify installation done messages display + $this->assertEquals( "Setting up database... done", + $this->getText( LINK_FORM . "ul/li[1]" ) ); + $this->assertEquals( "Creating tables... done", + $this->getText( LINK_FORM . "ul/li[2]" ) ); + $this->assertEquals( "Creating database user... done", + $this->getText( LINK_FORM . "ul/li[3]" ) ); + $this->assertEquals( "Populating default interwiki table... done", + $this->getText( LINK_FORM . "ul/li[4]" ) ); + $this->assertEquals( "Generating secret key... done", + $this->getText( LINK_FORM . "ul/li[5]" ) ); + $this->assertEquals( "Generating default upgrade key... done", + $this->getText( LINK_FORM . "ul/li[6]" ) ); + $this->assertEquals( "Creating administrator user account... done", + $this->getText( LINK_FORM . "ul/li[7]" ) ); + $this->assertEquals( "Creating main page with default content... done", + $this->getText( LINK_FORM . "ul/li[8]" ) ); + } + + public function testCompletePageUI() { + $databaseName = DB_NAME_PREFIX . "_complete_UI"; + parent::navigateCompletePage( $databaseName ); + + // 'Congratulations!' text display + $this->assertEquals( "Congratulations!", + $this->getText( LINK_FORM . "div[1]/div[2]/p[1]/b" ) ); + // 'LocalSettings.php' generated message display + $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.", + $this->getText( LINK_FORM . "div[1]/div[2]/p[2]" ) ); + + // 'Download LocalSettings.php'' link available + $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" ) ); + + // 'enter your wiki' link available + $this->assertTrue( $this->isElementPresent( "link=Folder/index.php enter your wiki" ) ); + } + + public function testRestartInstallation() { + parent::navigateConnetToDatabasePage(); + $this->click( "link=Restart installation" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // Restart installation' label should be available. + $this->assertEquals( "Restart installation", $this->getText( LINK_DIV . "h2" ) ); + + //'Do you want to clear all saved data that you have entered and restart the installation process?' label available + $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?", + $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" ) ); + // 'Back' button available + $this->assertTrue( $this->isElementPresent( "submit-back" ) ); + + // 'Restart' button available + $this->assertTrue( $this->isElementPresent( "submit-restart" ) ); + } + + public function testMediaWikiLogoAvailability() { + $databaseName = DB_NAME_PREFIX . "_mediawiki_logo"; + parent::navigateInitialpage(); + parent::mediaWikiLogoPresentInitialScreen(); + $this->click( "link=set up the wiki" ); + $this->waitForPageToLoad( PAGE_LOAD_TIME ); + + // 'Language' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Welcome to MediaWiki' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Connet to database' page + parent::mediaWikiLogoPresent(); + $this->type( "mysql_wgDBname", $databaseName ); + parent::clickContinueButton(); + + // 'Database setting' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Name' page + parent::mediaWikiLogoPresent(); + parent::completeNamePage(); + parent::clickContinueButton(); + + // 'Options' page + parent::mediaWikiLogoPresent(); + parent::clickContinueButton(); + + // 'Install' page + parent::mediaWikiLogoPresent(); + } + + public function testRightFramework() { + parent::navigateLanguagePage(); + // Verfy right framework texts display + $this->assertEquals( "Language", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[1]" ) ); + $this->assertEquals( "Existing wiki", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[2]" ) ); + $this->assertEquals( "Welcome to MediaWiki!", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[3]" ) ); + $this->assertEquals( "Connect to database", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[4]" ) ); + $this->assertEquals( "Upgrade existing installation", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[5]" ) ); + $this->assertEquals( "Database settings", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[6]" ) ); + $this->assertEquals( "Name", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[7]" ) ); + $this->assertEquals( "Options", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[8]" ) ); + $this->assertEquals( "Install", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[9]" ) ); + $this->assertEquals( "Complete!", + $this->getText( LINK_RIGHT_FRAMEWORK . "li[10]/span" ) ); + } } diff --git a/tests/selenium/suites/AddContentToNewPageTestCase.php b/tests/selenium/suites/AddContentToNewPageTestCase.php index 72e75e11e0..a74efc5d00 100644 --- a/tests/selenium/suites/AddContentToNewPageTestCase.php +++ b/tests/selenium/suites/AddContentToNewPageTestCase.php @@ -6,7 +6,7 @@ * @file * @ingroup Testing * Copyright (C) 2010 Nadeesha Weerasinghe - * http://www.calcey.com/ + * http://www.calcey.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,156 +27,151 @@ * */ - 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::LINK_START."Link title" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" ); - $this->clickShowPreviewBtn(); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify external links displayed on mediawiki preview - $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); - $correct = strstr( $source, "Google" ); - $this->assertEquals( $correct, true ); - - $this->click( SeleniumTestConstants::LINK_START."Google" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify horizontal line displayed on mediawiki preview - $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" )); - $this->deletePage( "new" ); - } + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::LINK_START . "Link title" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify external links displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $correct = strstr( $source, "Google" ); + $this->assertEquals( $correct, true ); + + $this->click( SeleniumTestConstants::LINK_START . "Google" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify horizontal line displayed on mediawiki preview + $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ) ); + $this->deletePage( "new" ); + } } diff --git a/tests/selenium/suites/CreateAccountTestCase.php b/tests/selenium/suites/CreateAccountTestCase.php index 5708bcff68..e29f2c7c56 100644 --- a/tests/selenium/suites/CreateAccountTestCase.php +++ b/tests/selenium/suites/CreateAccountTestCase.php @@ -6,7 +6,7 @@ * @file * @ingroup Testing * Copyright (C) 2010 Nadeesha Weerasinghe - * http://www.calcey.com/ + * http://www.calcey.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,87 +28,86 @@ */ 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $this->assertTrue($this->isElementPresent( "link=Create an account" )); - } - - // Verify Create account - public function testCreateAccount() { - - $this->click( "link=Log out" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->open( $this->getUrl().'/index.php?title=Main_Page' ); - - $this->click( "link=Log in / create account" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->click( "link=Create an account" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify for blank user name - $this->type( "wpName2", "" ); - $this->click( "wpCreateaccount" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify successful account creation for valid combination of 'Username', 'Password', 'Retype password' - $this->assertEquals( "Welcome, ".ucfirst( $this->userName )."!", - $this->getText( "Welcome,_".ucfirst( $this->userName )."!" )); - } + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $this->assertTrue( $this->isElementPresent( "link=Create an account" ) ); + } + + // Verify Create account + public function testCreateAccount() { + + $this->click( "link=Log out" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->open( $this->getUrl() . '/index.php?title=Main_Page' ); + + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->click( "link=Create an account" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify for blank user name + $this->type( "wpName2", "" ); + $this->click( "wpCreateaccount" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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/tests/selenium/suites/MovePageTestCase.php b/tests/selenium/suites/MovePageTestCase.php index 5263e7bbaf..3964dc17d5 100644 --- a/tests/selenium/suites/MovePageTestCase.php +++ b/tests/selenium/suites/MovePageTestCase.php @@ -6,7 +6,7 @@ * @file * @ingroup Testing * Copyright (C) 2010 Nadeesha Weerasinghe - * http://www.calcey.com/ + * http://www.calcey.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,90 +28,88 @@ */ 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $this->click( "link=".$displayName ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $this->type( SeleniumTestConstants::TEXT_EDITOR, $newPage." text" ); - $this->click( SeleniumTestConstants::BUTTON_SAVE ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify link 'Move' available - $this->assertTrue($this->isElementPresent( "link=Move" )); - - $this->click( "link=Move" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify search using new page name - $this->assertEquals( $displayName."move", $this->getText( "firstHeading" )); - - $this->type( "searchInput", $newPage ); - $this->click( "searchGoButton" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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 ); - } + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $this->click( "link=" . $displayName ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $this->type( SeleniumTestConstants::TEXT_EDITOR, $newPage . " text" ); + $this->click( SeleniumTestConstants::BUTTON_SAVE ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify link 'Move' available + $this->assertTrue( $this->isElementPresent( "link=Move" ) ); + + $this->click( "link=Move" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify search using new page name + $this->assertEquals( $displayName . "move", $this->getText( "firstHeading" ) ); + + $this->type( "searchInput", $newPage ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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/tests/selenium/suites/PageSearchTestCase.php b/tests/selenium/suites/PageSearchTestCase.php index fe71eadab5..bde1b576b1 100644 --- a/tests/selenium/suites/PageSearchTestCase.php +++ b/tests/selenium/suites/PageSearchTestCase.php @@ -6,7 +6,7 @@ * @file * @ingroup Testing * Copyright (C) 2010 Nadeesha Weerasinghe - * http://www.calcey.com/ + * http://www.calcey.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,78 +28,75 @@ */ 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( SeleniumTestConstants::INPUT_SEARCH_BOX, "calcey qa" ); - $this->click( "searchGoButton" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( SeleniumTestConstants::TEXT_EDITOR , "Calcey QA team" ); - $this->click( "wpSave" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - } - - // Verify the functionality of the 'Search' button - public function testPageSearchBtnSearch() { - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" ); - $this->click( SeleniumTestConstants::BUTTON_SEARCH ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey web team" ); - $this->click( SeleniumTestConstants::BUTTON_SAVE ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify saved page is opened when the exact page name is given - $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" ); - $this->click( SeleniumTestConstants::BUTTON_SEARCH ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey" ); - $this->click( SeleniumTestConstants::BUTTON_SEARCH ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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"); - } + // Verify the functionality of the 'Go' button + public function testPageSearchBtnGo() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "calcey qa" ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey QA team" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + } + + // Verify the functionality of the 'Search' button + public function testPageSearchBtnSearch() { + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" ); + $this->click( SeleniumTestConstants::BUTTON_SEARCH ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey web team" ); + $this->click( SeleniumTestConstants::BUTTON_SAVE ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify saved page is opened when the exact page name is given + $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" ); + $this->click( SeleniumTestConstants::BUTTON_SEARCH ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey" ); + $this->click( SeleniumTestConstants::BUTTON_SEARCH ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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/tests/selenium/suites/UserPreferencesTestCase.php b/tests/selenium/suites/UserPreferencesTestCase.php index 3ceb3a9959..a68ea97d38 100644 --- a/tests/selenium/suites/UserPreferencesTestCase.php +++ b/tests/selenium/suites/UserPreferencesTestCase.php @@ -6,7 +6,7 @@ * @file * @ingroup Testing * Copyright (C) 2010 Nadeesha Weerasinghe - * http://www.calcey.com/ + * http://www.calcey.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,152 +28,147 @@ */ class UserPreferencesTestCase extends SeleniumTestCase { - - // Verify user information - public function testUserInfoDisplay() { - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->click( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->click( SeleniumTestConstants::LINK_START."Change password" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( "wpPassword", "12345" ); - $this->type( "wpNewPassword", "54321" ); - $this->type( "wpRetype", "54321" ); - $this->click( "//input[@value='Change password']" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->assertEquals( "Preferences", $this->getText( "firstHeading" )); - - $this->click( SeleniumTestConstants::LINK_START."Change password" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( "wpPassword", "54321" ); - $this->type( "wpNewPassword", "12345" ); - $this->type( "wpRetype", "12345" ); - $this->click( "//input[@value='Change password']" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $this->assertEquals( "Preferences", $this->getText( "firstHeading" )); - - $this->click( SeleniumTestConstants::LINK_START."Change password" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( "wpPassword", "54321" ); - $this->type( "wpNewPassword", "12345" ); - $this->type( "wpRetype", "12345" ); - $this->click( "//input[@value='Change password']" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - } - - // Verify successful preferences save - public function testSuccessfullSave() { - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->click( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( "mw-input-realname", "Test User" ); - $this->click( "prefcontrol" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - } - - // Verify change signature - public function testChangeSignature() { - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - $this->click( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->type( "mw-input-nickname", "TestSignature" ); - $this->click( "prefcontrol" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify change user signature - $this->assertEquals( "TestSignature", $this->getText( SeleniumTestConstants::LINK_START."TestSignature" )); - $this->type( "mw-input-nickname", "Test" ); - $this->click( "prefcontrol" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - } - - // Verify change date format - public function testChangeDateFormatTimeZone() { - - $this->open( $this->getUrl() . - '/index.php?title=Main_Page&action=edit' ); - - $this->click( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - $this->click( SeleniumTestConstants::LINK_START."Date and time" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - $this->click( "mw-input-date-dmy" ); - $this->select( "mw-input-timecorrection", "label=Asia/Colombo" ); - $this->click( "prefcontrol" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::LINK_START."My preferences" ); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify restoring all default settings - $this->assertEquals( "Restore all default settings", - $this->getText( SeleniumTestConstants::LINK_START."Restore all default settings" )); - - $this->click("//*[@id='preferences']/div/a"); - $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); - - // Verify preferences saved successfully - $this->assertEquals("Your preferences have been saved.", - $this->getText("//div[@id='bodyContent']/div[4]/strong/p")); - } + // Verify user information + public function testUserInfoDisplay() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->click( SeleniumTestConstants::LINK_START . "Change password" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( "wpPassword", "12345" ); + $this->type( "wpNewPassword", "54321" ); + $this->type( "wpRetype", "54321" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) ); + + $this->click( SeleniumTestConstants::LINK_START . "Change password" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( "wpPassword", "54321" ); + $this->type( "wpNewPassword", "12345" ); + $this->type( "wpRetype", "12345" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) ); + + $this->click( SeleniumTestConstants::LINK_START . "Change password" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( "wpPassword", "54321" ); + $this->type( "wpNewPassword", "12345" ); + $this->type( "wpRetype", "12345" ); + $this->click( "//input[@value='Change password']" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + } + + // Verify successful preferences save + public function testSuccessfullSave() { + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( "mw-input-realname", "Test User" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + } + + // Verify change signature + public function testChangeSignature() { + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->type( "mw-input-nickname", "TestSignature" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify change user signature + $this->assertEquals( "TestSignature", $this->getText( SeleniumTestConstants::LINK_START . "TestSignature" ) ); + $this->type( "mw-input-nickname", "Test" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + } + + // Verify change date format + public function testChangeDateFormatTimeZone() { + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + + $this->click( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + $this->click( SeleniumTestConstants::LINK_START . "Date and time" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + $this->click( "mw-input-date-dmy" ); + $this->select( "mw-input-timecorrection", "label=Asia/Colombo" ); + $this->click( "prefcontrol" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::LINK_START . "My preferences" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify restoring all default settings + $this->assertEquals( "Restore all default settings", + $this->getText( SeleniumTestConstants::LINK_START . "Restore all default settings" ) ); + + $this->click( "//*[@id='preferences']/div/a" ); + $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // 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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); + + // Verify preferences saved successfully + $this->assertEquals( "Your preferences have been saved.", + $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) ); + } } diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index f1eb833cbc..1e51d80939 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -59,7 +59,7 @@ class TestRecorder { if ( $success == $total ) { print $this->term->color( 32 ) . "ALL TESTS PASSED!"; } else { - $failed = $total - $success ; + $failed = $total - $success; print $this->term->color( 31 ) . "$failed tests failed!"; } @@ -69,10 +69,10 @@ class TestRecorder { } } -class DbTestPreviewer extends TestRecorder { - protected $lb; // /< Database load balancer - protected $db; // /< Database connection to the main DB - protected $curRun; // /< run ID number for the current run +class DbTestPreviewer extends TestRecorder { + protected $lb; // /< Database load balancer + protected $db; // /< Database connection to the main DB + protected $curRun; // /< run ID number for the current run protected $prevRun; // /< run ID number for the previous run, if any protected $results; // /< Result array @@ -94,9 +94,9 @@ class DbTestPreviewer extends TestRecorder { function start() { parent::start(); - if ( ! $this->db->tableExists( 'testrun', __METHOD__ ) - || ! $this->db->tableExists( 'testitem', __METHOD__ ) ) - { + if ( !$this->db->tableExists( 'testrun', __METHOD__ ) + || !$this->db->tableExists( 'testitem', __METHOD__ ) + ) { print "WARNING> `testrun` table not found in database.\n"; $this->prevRun = false; } else { @@ -134,8 +134,8 @@ class DbTestPreviewer extends TestRecorder { foreach ( $res as $row ) { if ( !$this->parent->regex - || preg_match( "/{$this->parent->regex}/i", $row->ti_name ) ) - { + || preg_match( "/{$this->parent->regex}/i", $row->ti_name ) + ) { $prevResults[$row->ti_name] = $row->ti_success; } } @@ -195,34 +195,34 @@ class DbTestPreviewer extends TestRecorder { private function getTestStatusInfo( $testname, $after ) { // If we're looking at a test that has just been removed, then say when it first appeared. if ( $after == 'n' ) { - $changedRun = $this->db->selectField ( 'testitem', + $changedRun = $this->db->selectField( 'testitem', 'MIN(ti_run)', array( 'ti_name' => $testname ), __METHOD__ ); - $appear = $this->db->selectRow ( 'testrun', + $appear = $this->db->selectRow( 'testrun', array( 'tr_date', 'tr_mw_version' ), array( 'tr_id' => $changedRun ), __METHOD__ ); return "First recorded appearance: " - . date( "d-M-Y H:i:s", strtotime ( $appear->tr_date ) ) - . ", " . $appear->tr_mw_version; + . date( "d-M-Y H:i:s", strtotime( $appear->tr_date ) ) + . ", " . $appear->tr_mw_version; } // Otherwise, this test has previous recorded results. // See when this test last had a different result to what we're seeing now. $conds = array( - 'ti_name' => $testname, + 'ti_name' => $testname, 'ti_success' => ( $after == 'f' ? "1" : "0" ) ); if ( $this->curRun ) { - $conds[] = "ti_run != " . $this->db->addQuotes ( $this->curRun ); + $conds[] = "ti_run != " . $this->db->addQuotes( $this->curRun ); } - $changedRun = $this->db->selectField ( 'testitem', 'MAX(ti_run)', $conds, __METHOD__ ); + $changedRun = $this->db->selectField( 'testitem', 'MAX(ti_run)', $conds, __METHOD__ ); // If no record of ever having had a different result. - if ( is_null ( $changedRun ) ) { + if ( is_null( $changedRun ) ) { if ( $after == "f" ) { return "Has never passed"; } else { @@ -233,27 +233,26 @@ class DbTestPreviewer extends TestRecorder { // Otherwise, we're looking at a test whose status has changed. // (i.e. it used to work, but now doesn't; or used to fail, but is now fixed.) // In this situation, give as much info as we can as to when it changed status. - $pre = $this->db->selectRow ( 'testrun', + $pre = $this->db->selectRow( 'testrun', array( 'tr_date', 'tr_mw_version' ), array( 'tr_id' => $changedRun ), __METHOD__ ); - $post = $this->db->selectRow ( 'testrun', + $post = $this->db->selectRow( 'testrun', array( 'tr_date', 'tr_mw_version' ), - array( "tr_id > " . $this->db->addQuotes ( $changedRun ) ), + array( "tr_id > " . $this->db->addQuotes( $changedRun ) ), __METHOD__, array( "LIMIT" => 1, "ORDER BY" => 'tr_id' ) ); if ( $post ) { - $postDate = date( "d-M-Y H:i:s", strtotime ( $post->tr_date ) ) . ", {$post->tr_mw_version}"; + $postDate = date( "d-M-Y H:i:s", strtotime( $post->tr_date ) ) . ", {$post->tr_mw_version}"; } else { $postDate = 'now'; } return ( $after == "f" ? "Introduced" : "Fixed" ) . " between " - . date( "d-M-Y H:i:s", strtotime ( $pre->tr_date ) ) . ", " . $pre->tr_mw_version - . " and $postDate"; - + . date( "d-M-Y H:i:s", strtotime( $pre->tr_date ) ) . ", " . $pre->tr_mw_version + . " and $postDate"; } /** @@ -264,10 +263,9 @@ class DbTestPreviewer extends TestRecorder { $this->lb->closeAll(); parent::end(); } - } -class DbTestRecorder extends DbTestPreviewer { +class DbTestRecorder extends DbTestPreviewer { var $version; /** @@ -277,9 +275,9 @@ class DbTestRecorder extends DbTestPreviewer { function start() { $this->db->begin( __METHOD__ ); - if ( ! $this->db->tableExists( 'testrun' ) - || ! $this->db->tableExists( 'testitem' ) ) - { + if ( !$this->db->tableExists( 'testrun' ) + || !$this->db->tableExists( 'testitem' ) + ) { print "WARNING> `testrun` table not found in database. Trying to create table.\n"; $this->db->sourceFile( $this->db->patchPath( 'patch-testrun.sql' ) ); echo "OK, resuming.\n"; @@ -289,18 +287,18 @@ class DbTestRecorder extends DbTestPreviewer { $this->db->insert( 'testrun', array( - 'tr_date' => $this->db->timestamp(), - 'tr_mw_version' => $this->version, + 'tr_date' => $this->db->timestamp(), + 'tr_mw_version' => $this->version, 'tr_php_version' => phpversion(), - 'tr_db_version' => $this->db->getServerVersion(), - 'tr_uname' => php_uname() + 'tr_db_version' => $this->db->getServerVersion(), + 'tr_uname' => php_uname() ), __METHOD__ ); - if ( $this->db->getType() === 'postgres' ) { - $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' ); - } else { - $this->curRun = $this->db->insertId(); - } + if ( $this->db->getType() === 'postgres' ) { + $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' ); + } else { + $this->curRun = $this->db->insertId(); + } } /** @@ -314,8 +312,8 @@ class DbTestRecorder extends DbTestPreviewer { $this->db->insert( 'testitem', array( - 'ti_run' => $this->curRun, - 'ti_name' => $test, + 'ti_run' => $this->curRun, + 'ti_name' => $test, 'ti_success' => $result ? 1 : 0, ), __METHOD__ ); @@ -328,7 +326,8 @@ class TestFileIterator implements Iterator { private $parserTest; /* An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit) */ private $index = 0; private $test; - private $section = null; /** String|null: current test section being analyzed */ + private $section = null; + /** String|null: current test section being analyzed */ private $sectionData = array(); private $lineNum; private $eof; @@ -395,7 +394,7 @@ class TestFileIterator implements Iterator { $this->section = strtolower( $matches[1] ); if ( $this->section == 'endarticle' ) { - $this->checkSection( 'text' ); + $this->checkSection( 'text' ); $this->checkSection( 'article' ); $this->parserTest->addArticle( ParserTest::chomp( $this->sectionData['article'] ), $this->sectionData['text'], $this->lineNum ); @@ -438,8 +437,8 @@ class TestFileIterator implements Iterator { } if ( $this->section == 'end' ) { - $this->checkSection( 'test' ); - $this->checkSection( 'input' ); + $this->checkSection( 'test' ); + $this->checkSection( 'input' ); $this->checkSection( 'result' ); if ( !isset( $this->sectionData['options'] ) ) { @@ -451,7 +450,8 @@ class TestFileIterator implements Iterator { } if ( ( ( preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] ) && !$this->parserTest->runDisabled ) - || !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] ) ) ) { + || !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] ) ) + ) { # disabled test $this->clearSection(); @@ -464,17 +464,17 @@ class TestFileIterator implements Iterator { # We are really going to run the test, run pending hooks and hooks function wfDebug( __METHOD__ . " unleashing delayed test for: {$this->sectionData['test']}" ); $hooksResult = $delayedParserTest->unleash( $this->parserTest ); - if( !$hooksResult ) { + if ( !$hooksResult ) { # Some hook reported an issue. Abort. return false; } $this->test = array( - 'test' => ParserTest::chomp( $this->sectionData['test'] ), - 'input' => ParserTest::chomp( $this->sectionData['input'] ), - 'result' => ParserTest::chomp( $this->sectionData['result'] ), + 'test' => ParserTest::chomp( $this->sectionData['test'] ), + 'input' => ParserTest::chomp( $this->sectionData['input'] ), + 'result' => ParserTest::chomp( $this->sectionData['result'] ), 'options' => ParserTest::chomp( $this->sectionData['options'] ), - 'config' => ParserTest::chomp( $this->sectionData['config'] ), + 'config' => ParserTest::chomp( $this->sectionData['config'] ), ); return true; @@ -516,18 +516,18 @@ class TestFileIterator implements Iterator { * @param $token String: expected token that should have been mentionned before closing this section */ private function checkSection( $token ) { - if( is_null( $this->section ) ) { + if ( is_null( $this->section ) ) { throw new MWException( __METHOD__ . " can not verify a null section!\n" ); } - if( !isset($this->sectionData[$token]) ) { + if ( !isset( $this->sectionData[$token] ) ) { throw new MWException( sprintf( "'%s' without '%s' at line %s of %s\n", $this->section, $token, $this->lineNum, $this->file - )); + ) ); } return true; } @@ -551,7 +551,7 @@ class DelayedParserTest { * Call to this will erase any hooks function that were pending. */ public function reset() { - $this->hooks = array(); + $this->hooks = array(); $this->fnHooks = array(); } @@ -560,23 +560,22 @@ class DelayedParserTest { * Should be the case if we found the parserTest is not disabled */ public function unleash( &$parserTest ) { - if( !($parserTest instanceof ParserTest || $parserTest instanceof NewParserTest - ) ) { + if ( !( $parserTest instanceof ParserTest || $parserTest instanceof NewParserTest ) ) { throw new MWException( __METHOD__ . " must be passed an instance of ParserTest or NewParserTest classes\n" ); } # Trigger delayed hooks. Any failure will make us abort - foreach( $this->hooks as $hook ) { + foreach ( $this->hooks as $hook ) { $ret = $parserTest->requireHook( $hook ); - if( !$ret ) { + if ( !$ret ) { return false; } } # Trigger delayed function hooks. Any failure will make us abort - foreach( $this->fnHooks as $fnHook ) { + foreach ( $this->fnHooks as $fnHook ) { $ret = $parserTest->requireFunctionHook( $fnHook ); - if( !$ret ) { + if ( !$ret ) { return false; } } @@ -592,6 +591,7 @@ class DelayedParserTest { public function requireHook( $hook ) { $this->hooks[] = $hook; } + /** * Similar to ParserTest object but does not run anything * Use unleash() to really execute the hook function -- 2.20.1