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