diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:44:38 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:44:38 +0200 |
| commit | 69bffb7fe85347621f41c0baed839452e72930e1 (patch) | |
| tree | 8446bced1732932fd741e91ff8dba88b1e56693b /protected/tests/functional | |
| parent | a098922f681a9a1362202580a26b132501df4b1b (diff) | |
Erstes Yii Projekt
Diffstat (limited to 'protected/tests/functional')
| -rw-r--r-- | protected/tests/functional/SiteTest.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/protected/tests/functional/SiteTest.php b/protected/tests/functional/SiteTest.php new file mode 100644 index 0000000..cb9727c --- /dev/null +++ b/protected/tests/functional/SiteTest.php @@ -0,0 +1,47 @@ +<?php + +class SiteTest extends WebTestCase +{ + public function testIndex() + { + $this->open(''); + $this->assertTextPresent('Welcome'); + } + + public function testContact() + { + $this->open('?r=site/contact'); + $this->assertTextPresent('Contact Us'); + $this->assertElementPresent('name=ContactForm[name]'); + + $this->type('name=ContactForm[name]','tester'); + $this->type('name=ContactForm[email]','tester@example.com'); + $this->type('name=ContactForm[subject]','test subject'); + $this->click("//input[@value='Submit']"); + $this->waitForTextPresent('Body cannot be blank.'); + } + + public function testLoginLogout() + { + $this->open(''); + // ensure the user is logged out + if($this->isTextPresent('Logout')) + $this->clickAndWait('link=Logout (demo)'); + + // test login process, including validation + $this->clickAndWait('link=Login'); + $this->assertElementPresent('name=LoginForm[username]'); + $this->type('name=LoginForm[username]','demo'); + $this->click("//input[@value='Login']"); + $this->waitForTextPresent('Password cannot be blank.'); + $this->type('name=LoginForm[password]','demo'); + $this->clickAndWait("//input[@value='Login']"); + $this->assertTextNotPresent('Password cannot be blank.'); + $this->assertTextPresent('Logout'); + + // test logout process + $this->assertTextNotPresent('Login'); + $this->clickAndWait('link=Logout (demo)'); + $this->assertTextPresent('Login'); + } +} |
