MediaWiki  REL1_21
UserPreferencesTestCase.php
Go to the documentation of this file.
00001 <?php
00026 class UserPreferencesTestCase extends SeleniumTestCase {
00027         // Verify user information
00028         public function testUserInfoDisplay() {
00029 
00030                 $this->open( $this->getUrl() .
00031                         '/index.php?title=Main_Page&action=edit' );
00032                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00033                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00034 
00035                 // Verify correct username displayed in User Preferences
00036                 $this->assertEquals( $this->getText( "//li[@id='pt-userpage']/a" ),
00037                         $this->getText( "//table[@id='mw-htmlform-info']/tbody/tr[1]/td[2]" ) );
00038 
00039                 // Verify existing Signature Displayed correctly
00040                 $this->assertEquals( $this->selenium->getUser(),
00041                         $this->getTable( "mw-htmlform-signature.0.1" ) );
00042         }
00043 
00044         // Verify change password
00045         public function testChangePassword() {
00046 
00047                 $this->open( $this->getUrl() .
00048                         '/index.php?title=Main_Page&action=edit' );
00049                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00050                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00051 
00052                 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
00053                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00054 
00055                 $this->type( "wpPassword", "12345" );
00056                 $this->type( "wpNewPassword", "54321" );
00057                 $this->type( "wpRetype", "54321" );
00058                 $this->click( "//input[@value='Change password']" );
00059                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00060 
00061                 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) );
00062 
00063                 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
00064                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00065 
00066                 $this->type( "wpPassword", "54321" );
00067                 $this->type( "wpNewPassword", "12345" );
00068                 $this->type( "wpRetype", "12345" );
00069                 $this->click( "//input[@value='Change password']" );
00070                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00071                 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) );
00072 
00073                 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
00074                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00075 
00076                 $this->type( "wpPassword", "54321" );
00077                 $this->type( "wpNewPassword", "12345" );
00078                 $this->type( "wpRetype", "12345" );
00079                 $this->click( "//input[@value='Change password']" );
00080                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00081         }
00082 
00083         // Verify successful preferences save
00084         public function testSuccessfullSave() {
00085 
00086                 $this->open( $this->getUrl() .
00087                         '/index.php?title=Main_Page&action=edit' );
00088                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00089                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00090 
00091                 $this->type( "mw-input-realname", "Test User" );
00092                 $this->click( "prefcontrol" );
00093                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00094 
00095                 // Verify  "Your preferences have been saved." message
00096                 $this->assertEquals( "Your preferences have been saved.",
00097                         $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
00098                 $this->type( "mw-input-realname", "" );
00099                 $this->click( "prefcontrol" );
00100                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00101         }
00102 
00103         // Verify change signature
00104         public function testChangeSignature() {
00105                 $this->open( $this->getUrl() .
00106                         '/index.php?title=Main_Page&action=edit' );
00107                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00108                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00109 
00110                 $this->type( "mw-input-nickname", "TestSignature" );
00111                 $this->click( "prefcontrol" );
00112                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00113 
00114                 // Verify change user signature
00115                 $this->assertEquals( "TestSignature", $this->getText( SeleniumTestConstants::LINK_START . "TestSignature" ) );
00116                 $this->type( "mw-input-nickname", "Test" );
00117                 $this->click( "prefcontrol" );
00118                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00119         }
00120 
00121         // Verify change date format
00122         public function testChangeDateFormatTimeZone() {
00123                 $this->open( $this->getUrl() .
00124                         '/index.php?title=Main_Page&action=edit' );
00125 
00126                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00127                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00128                 $this->click( SeleniumTestConstants::LINK_START . "Date and time" );
00129                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00130 
00131                 $this->click( "mw-input-date-dmy" );
00132                 $this->select( "mw-input-timecorrection", "label=Asia/Colombo" );
00133                 $this->click( "prefcontrol" );
00134                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00135 
00136                 // Verify Date format and time zome saved
00137                 $this->assertEquals( "Your preferences have been saved.",
00138                         $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
00139         }
00140 
00141         // Verify restoring all default settings
00142         public function testSetAllDefault() {
00143                 $this->open( $this->getUrl() .
00144                         '/index.php?title=Main_Page&action=edit' );
00145                 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
00146                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00147 
00148                 // Verify restoring all default settings
00149                 $this->assertEquals( "Restore all default settings",
00150                         $this->getText( SeleniumTestConstants::LINK_START . "Restore all default settings" ) );
00151 
00152                 $this->click( "//*[@id='preferences']/div/a" );
00153                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00154 
00155                 // Verify 'This can not be undone' warning message displayed
00156                 $this->assertTrue( $this->isElementPresent( "//input[@value='Restore all default settings']" ) );
00157 
00158                 // Verify 'Restore all default settings' button available
00159                 $this->assertEquals( "You can use this page to reset your preferences to the site defaults. This cannot be undone.",
00160                         $this->getText( "//div[@id='bodyContent']/p" ) );
00161 
00162                 $this->click( "//input[@value='Restore all default settings']" );
00163                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00164 
00165                 // Verify preferences saved successfully
00166                 $this->assertEquals( "Your preferences have been saved.",
00167                         $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
00168         }
00169 }
00170