SiteTest.php 1.4 KB

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