SiteTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class SiteTest extends WebTestCase
  3. {
  4. public function testContact()
  5. {
  6. $this->open('site/contact');
  7. $this->assertTextPresent('Contact Us');
  8. $this->assertElementPresent('name=ContactForm[name]');
  9. $this->type('name=ContactForm[name]','tester');
  10. $this->type('name=ContactForm[email]','tester@example.com');
  11. $this->type('name=ContactForm[subject]','test subject');
  12. $this->clickAndWait("//input[@value='Submit']");
  13. $this->assertTextPresent('Body cannot be blank.');
  14. }
  15. public function testLoginLogout()
  16. {
  17. $this->open('');
  18. // ensure the user is logged out
  19. if($this->isTextPresent('Logout'))
  20. $this->clickAndWait('link=Logout');
  21. // test login process, including validation
  22. $this->clickAndWait('link=Login');
  23. $this->assertElementPresent('name=LoginForm[username]');
  24. $this->type('name=LoginForm[username]','demo');
  25. $this->clickAndWait("//input[@value='Login']");
  26. $this->assertTextPresent('Password cannot be blank.');
  27. $this->type('name=LoginForm[password]','demo');
  28. $this->clickAndWait("//input[@value='Login']");
  29. $this->assertTextNotPresent('Password cannot be blank.');
  30. $this->assertTextPresent('Logout');
  31. // test logout process
  32. $this->assertTextNotPresent('Login');
  33. $this->clickAndWait('link=Logout');
  34. $this->assertTextPresent('Login');
  35. }
  36. }