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