public function testLoginLogout()
{
$this->open('');
// ensure the user is logged out
if ($this->isTextPresent('Logout')) {
$this->clickAndWait('link=Logout');
}
// test login process, including validation
$this->clickAndWait('link=Login');
$this->assertElementPresent('name=LoginForm[username]');
$this->type('name=LoginForm[username]', 'admin');
$this->clickAndWait("//input[@value='Login']");
$this->assertTextPresent('Password cannot be blank.');
$this->type('name=LoginForm[password]', 'admin');
$this->clickAndWait("//input[@value='Login']");
$this->assertTextNotPresent('Password cannot be blank.');
$this->assertTextPresent('Logout');
// test logout process
$this->assertTextNotPresent('Login');
$this->clickAndWait('link=Logout (admin)');
$this->assertTextPresent('Login');
}