Created
January 9, 2013 12:33
-
-
Save kallepersson/4492818 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class SiteTest extends WebTestCase | |
| { | |
| private $username = 'epicuser'; | |
| private $password = 'supersecretpassword'; | |
| private $order_customer_data = array( | |
| 'Customer[uid]' => '8705081337', | |
| 'Customer[first_name]' => 'Test', | |
| 'Customer[last_name]' => 'Testsson', | |
| 'Customer[phone]' => '0737001300', | |
| 'Customer[email]' => '[email protected]', | |
| 'Customer[organisation_number]' => '8705081337', | |
| 'Customer[company_name]' => 'Testföretaget', | |
| 'Customer[organisation_phone]' => '04324230', | |
| 'Customer[organisation_email]' => '[email protected]', | |
| 'Customer[address]' => 'Testgatan 2', | |
| 'Customer[post_number]' => '5321 20', | |
| 'Customer[city]' => 'Teststaden', | |
| 'ExpectedTb' => '1234', | |
| ); | |
| //Used for almost every test | |
| public function login() { | |
| $this->open(''); | |
| if($this->isElementPresent('id=login-form')) { | |
| $this->type('name=LoginForm[username]',$this->username); | |
| $this->type('name=LoginForm[password]',$this->password); | |
| $this->clickAndWait("//input[@type='submit']"); | |
| } | |
| } | |
| public function logout() { | |
| if($this->isTextPresent('Logga ut')) { | |
| $this->clickAndWait('link=Logga ut'); | |
| } | |
| } | |
| public function testLoginLogout() | |
| { | |
| $this->open(''); | |
| $this->logout(); | |
| //Assertion 1: Login Form exists | |
| $this->assertElementPresent('id=login-form'); | |
| //Assertion 1: Login Form exists | |
| $this->type('name=LoginForm[username]',$this->username); | |
| $this->type('name=LoginForm[password]',$this->password); | |
| $this->clickAndWait("//input[@type='submit']"); | |
| //Assertion 3: We aren't on login page anymore | |
| $this->assertElementNotPresent('id=login-form'); | |
| //Assertion 4: We can log out and we're directed back to login page | |
| $this->clickAndWait('link=Logga ut'); | |
| $this->assertElementPresent('id=login-form'); | |
| } | |
| //Put this in OrderTest later... | |
| public function testCreateOrderWithNewCustomer() | |
| { | |
| $this->login(); | |
| $this->clickAndWait('link=Beställningar'); | |
| $this->clickAndWait('link=Ny beställning'); | |
| //Assertion 1: We have a customer form | |
| $this->assertElementPresent('id=customer-form'); | |
| $this->select('name=Customer[suffix]', 'value=EF'); | |
| foreach($this->order_customer_data as $name => $value) { | |
| $this->type('name='.$name, $value); | |
| } | |
| //TODO Add Order row test | |
| $this->click('id=addOrderItemRow'); | |
| $this->waitForElementPresent('name=article_id'); | |
| //TODO: Fix this locator to allow for multiple oirs/ors in future | |
| $this->type('name=article_id', 114089); | |
| $this->type('name=OrderItemRow[price]', 1234); | |
| $this->type('name=OrderItemRow[controlled_tb]', 10); | |
| //TODO: Fix this locator to allow for multiple oirs/ors in future | |
| $this->click('link=Spara'); | |
| $this->storeConfirmation('ok'); | |
| //TODO Add Orderfile test (how?) | |
| //Assertion 2: We managed to create the order and land on order page | |
| $this->clickAndWait('link=Skapa'); | |
| $this->assertElementPresent('id=order'); | |
| //Assertion 3-16: Make sure the customer data was carried over | |
| /* | |
| foreach($this->order_customer_data as $name => $value) { | |
| $this->assertTextPresent($value); | |
| } | |
| //Assertion 17: Make sure the product was added | |
| $this->assertTextPresent('114089'); | |
| */ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment