MediaWiki
REL1_19
|
00001 <?php 00002 00030 Class CreateAccountTestCase extends SeleniumTestCase { 00031 00032 // Change these values before run the test 00033 private $userName = "yourname4000"; 00034 private $password = "yourpass4000"; 00035 00036 // Verify 'Log in/create account' link existance in Main page. 00037 public function testMainPageLink() { 00038 00039 $this->click( "link=Log out" ); 00040 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00041 00042 $this->open( $this->getUrl().'/index.php?title=Main_Page' ); 00043 $this->assertTrue($this->isElementPresent( "link=Log in / create account" )); 00044 } 00045 00046 // Verify 'Create an account' link existance in 'Log in / create account' Page. 00047 public function testCreateAccountPageLink() { 00048 00049 $this->click( "link=Log out" ); 00050 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00051 00052 $this->open( $this->getUrl().'/index.php?title=Main_Page' ); 00053 00054 // click Log in / create account link to open Log in / create account' page 00055 $this->click( "link=Log in / create account" ); 00056 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00057 $this->assertTrue($this->isElementPresent( "link=Create an account" )); 00058 } 00059 00060 // Verify Create account 00061 public function testCreateAccount() { 00062 00063 $this->click( "link=Log out" ); 00064 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00065 00066 $this->open( $this->getUrl().'/index.php?title=Main_Page' ); 00067 00068 $this->click( "link=Log in / create account" ); 00069 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00070 00071 $this->click( "link=Create an account" ); 00072 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00073 00074 // Verify for blank user name 00075 $this->type( "wpName2", "" ); 00076 $this->click( "wpCreateaccount" ); 00077 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00078 $this->assertEquals( "Login error\n You have not specified a valid user name.", 00079 $this->getText( "//div[@id='bodyContent']/div[4]" )); 00080 00081 // Verify for invalid user name 00082 $this->type( "wpName2", "@" ); 00083 $this->click("wpCreateaccount" ); 00084 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00085 $this->assertEquals( "Login error\n You have not specified a valid user name.", 00086 $this->getText( "//div[@id='bodyContent']/div[4]" )); 00087 00088 // start of test for blank password 00089 $this->type( "wpName2", $this->userName); 00090 $this->type( "wpPassword2", "" ); 00091 $this->click( "wpCreateaccount" ); 00092 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00093 $this->assertEquals( "Login error\n Passwords must be at least 1 character.", 00094 $this->getText("//div[@id='bodyContent']/div[4]" )); 00095 00096 $this->type( "wpName2", $this->userName ); 00097 $this->type( "wpPassword2", $this->password ); 00098 $this->click( "wpCreateaccount" ); 00099 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00100 $this->assertEquals( "Login error\n The passwords you entered do not match.", 00101 $this->getText( "//div[@id='bodyContent']/div[4]" )); 00102 00103 $this->type( "wpName2", $this->userName ); 00104 $this->type( "wpPassword2", $this->password ); 00105 $this->type( "wpRetype", $this->password ); 00106 $this->click( "wpCreateaccount" ); 00107 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME ); 00108 00109 // Verify successful account creation for valid combination of 'Username', 'Password', 'Retype password' 00110 $this->assertEquals( "Welcome, ".ucfirst( $this->userName )."!", 00111 $this->getText( "Welcome,_".ucfirst( $this->userName )."!" )); 00112 } 00113 } 00114