ORIENT/tests/functional/backend/AuthTest.php

91 lines
3.1 KiB
PHP
Raw Normal View History

<?php
class AuthTest extends UiTestCase
{
2014-06-17 10:21:07 +00:00
public function testSignInAndOut()
{
$this->open('backend');
$cssLogoutLink = '#layout-mainmenu .mainmenu-accountmenu > ul > li:first-child > a';
2014-06-17 10:21:07 +00:00
try {
$this->assertTitle('Administration Area');
$this->assertTrue($this->isElementPresent("name=login"));
$this->assertTrue($this->isElementPresent("name=password"));
$this->assertTrue($this->isElementPresent("//button[@type='submit']"));
$this->verifyText("//button[@type='submit']", "Login");
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
2014-06-17 10:21:07 +00:00
/*
* Sign in
*/
$this->type("name=login", TEST_SELENIUM_USER);
$this->type("name=password", TEST_SELENIUM_PASS);
$this->click("//button[@type='submit']");
$this->waitForPageToLoad("30000");
2014-06-17 10:21:07 +00:00
try {
$this->assertTitle('Dashboard | October CMS');
$this->assertTrue($this->isElementPresent('css='.$cssLogoutLink));
2014-06-17 10:21:07 +00:00
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->verifyText('css='.$cssLogoutLink, "Sign out");
2014-06-17 10:21:07 +00:00
/*
* Log out
*/
$this->click('css='.$cssLogoutLink);
2014-06-17 10:21:07 +00:00
$this->waitForPageToLoad("30000");
2014-06-17 10:21:07 +00:00
try {
$this->assertTitle('Administration Area');
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
2014-06-17 10:21:07 +00:00
public function testPasswordReset()
{
$this->open('backend');
2014-06-17 10:21:07 +00:00
try {
$this->assertTrue($this->isElementPresent("link=exact:Forgot your password?"));
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
2014-06-17 10:21:07 +00:00
$this->click('link=exact:Forgot your password?');
$this->waitForPageToLoad("30000");
2014-06-17 10:21:07 +00:00
try {
$this->assertTrue($this->isElementPresent("//button[@type='submit']"));
$this->verifyText("//button[@type='submit']", "Restore");
$this->assertTrue($this->isElementPresent("link=Cancel"));
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
2014-06-17 10:21:07 +00:00
$this->type("name=login", TEST_SELENIUM_USER);
sleep(1);
$this->click("//button[@type='submit']");
$this->waitForPageToLoad("30000");
2014-06-17 10:21:07 +00:00
try {
$this->assertTitle('Administration Area');
$this->assertTrue($this->isElementPresent("css=p.flash-message.success"));
$this->verifyText("css=p.flash-message.success", "An email has been sent to your email address with password restore instructions.×");
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
}
}