Commit 70463d53 by Johnny Theill

fix tests

parent fa661221
...@@ -10,21 +10,22 @@ $loginPage = LoginPage::openBy($I); ...@@ -10,21 +10,22 @@ $loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data'); $I->amGoingTo('submit login form with no data');
$loginPage->login('', ''); $loginPage->login('', '');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials'); $I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong'); $loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Incorrect username or password.'); $I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials'); $I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0'); $loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged'); $I->expectTo('see that user is logged');
$I->see('Logout (erau)'); $I->see('Logout (erau)', 'ul.nav li a');
$I->dontSee('Login'); $I->dontSee('Login', 'ul.nav li a');
$I->dontSee('Signup'); $I->dontSee('Signup', 'ul.nav li a');
$I->click('Logout (erau)'); // Uncomment if using WebDriver
$I->dontSee('Logout (erau)'); //$I->click('Logout (erau)', 'ul.nav li a');
$I->see('Login'); //$I->dontSee('Logout (erau)', 'ul.nav li a');
//$I->see('Login', 'ul.nav li a');
...@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I); ...@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data'); $I->amGoingTo('submit login form with no data');
$loginPage->login('', ''); $loginPage->login('', '');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials'); $I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong'); $loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Incorrect username or password.'); $I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials'); $I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0'); $loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged'); $I->expectTo('see that user is logged');
$I->see('Logout (erau)'); $I->see('Logout (erau)', 'ul.nav li a');
$I->dontSee('Login'); $I->dontSee('Login', 'ul.nav li a');
$I->dontSee('Signup'); $I->dontSee('Signup', 'ul.nav li a');
$I->click('Logout (erau)');
$I->dontSee('Logout (erau)');
$I->see('Login');
...@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data'); ...@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data');
$contactPage->submit([]); $contactPage->submit([]);
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->see('Name cannot be blank'); $I->see('Name cannot be blank', '.help-block');
$I->see('Email cannot be blank'); $I->see('Email cannot be blank', '.help-block');
$I->see('Subject cannot be blank'); $I->see('Subject cannot be blank', '.help-block');
$I->see('Body cannot be blank'); $I->see('Body cannot be blank', '.help-block');
$I->see('The verification code is incorrect'); $I->see('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with not correct email'); $I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([ $contactPage->submit([
...@@ -28,11 +28,11 @@ $contactPage->submit([ ...@@ -28,11 +28,11 @@ $contactPage->submit([
'verifyCode' => 'testme', 'verifyCode' => 'testme',
]); ]);
$I->expectTo('see that email adress is wrong'); $I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline'); $I->dontSee('Name cannot be blank', '.help-block');
$I->see('Email is not a valid email address.'); $I->see('Email is not a valid email address.', '.help-block');
$I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Subject cannot be blank', '.help-block');
$I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-block');
$I->dontSee('The verification code is incorrect', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with correct data'); $I->amGoingTo('submit contact form with correct data');
$contactPage->submit([ $contactPage->submit([
......
...@@ -10,21 +10,22 @@ $loginPage = LoginPage::openBy($I); ...@@ -10,21 +10,22 @@ $loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data'); $I->amGoingTo('submit login form with no data');
$loginPage->login('', ''); $loginPage->login('', '');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials'); $I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong'); $loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Incorrect username or password.'); $I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials'); $I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0'); $loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged'); $I->expectTo('see that user is logged');
$I->see('Logout (erau)'); $I->see('Logout (erau)', 'ul.nav li a');
$I->dontSee('Login'); $I->dontSee('Login', 'ul.nav li a');
$I->dontSee('Signup'); $I->dontSee('Signup', 'ul.nav li a');
$I->click('Logout (erau)'); // Uncomment if using WebDriver
$I->dontSee('Logout (erau)'); //$I->click('Logout (erau)', 'ul.nav li a');
$I->see('Login'); //$I->dontSee('Logout (erau)', 'ul.nav li a');
//$I->see('Login', 'ul.nav li a');
...@@ -9,7 +9,7 @@ class SignupCest ...@@ -9,7 +9,7 @@ class SignupCest
{ {
/** /**
* This method is called after each cest class test method * This method is called before each cest class test method
* @param \Codeception\Event\Test $event * @param \Codeception\Event\Test $event
*/ */
public function _before($event) public function _before($event)
...@@ -37,7 +37,6 @@ class SignupCest ...@@ -37,7 +37,6 @@ class SignupCest
} }
/** /**
*
* @param \WebGuy $I * @param \WebGuy $I
* @param \Codeception\Scenario $scenario * @param \Codeception\Scenario $scenario
*/ */
...@@ -46,6 +45,7 @@ class SignupCest ...@@ -46,6 +45,7 @@ class SignupCest
$I->wantTo('ensure that signup works'); $I->wantTo('ensure that signup works');
$signupPage = SignupPage::openBy($I); $signupPage = SignupPage::openBy($I);
$I->see('Signup', 'h1');
$I->see('Please fill out the following fields to signup:'); $I->see('Please fill out the following fields to signup:');
$I->amGoingTo('submit signup form with no data'); $I->amGoingTo('submit signup form with no data');
...@@ -53,9 +53,9 @@ class SignupCest ...@@ -53,9 +53,9 @@ class SignupCest
$signupPage->submit([]); $signupPage->submit([]);
$I->expectTo('see validation errors'); $I->expectTo('see validation errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Email cannot be blank.'); $I->see('Email cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('submit signup form with not correct email'); $I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([ $signupPage->submit([
...@@ -64,9 +64,9 @@ class SignupCest ...@@ -64,9 +64,9 @@ class SignupCest
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that email adress is wrong'); $I->expectTo('see that email address is wrong');
$I->dontSee('Username cannot be blank.', '.help-inline'); $I->dontSee('Username cannot be blank.', '.help-block');
$I->dontSee('Password cannot be blank.', '.help-inline'); $I->dontSee('Password cannot be blank.', '.help-block');
$I->see('Email is not a valid email address.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block');
$I->amGoingTo('submit signup form with correct email'); $I->amGoingTo('submit signup form with correct email');
...@@ -77,6 +77,6 @@ class SignupCest ...@@ -77,6 +77,6 @@ class SignupCest
]); ]);
$I->expectTo('see that user logged in'); $I->expectTo('see that user logged in');
$I->see('Logout (tester)'); $I->see('Logout (tester)', 'ul.nav li a');
} }
} }
...@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data'); ...@@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data');
$contactPage->submit([]); $contactPage->submit([]);
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Contact', 'h1'); $I->see('Contact', 'h1');
$I->see('Name cannot be blank'); $I->see('Name cannot be blank', '.help-block');
$I->see('Email cannot be blank'); $I->see('Email cannot be blank', '.help-block');
$I->see('Subject cannot be blank'); $I->see('Subject cannot be blank', '.help-block');
$I->see('Body cannot be blank'); $I->see('Body cannot be blank', '.help-block');
$I->see('The verification code is incorrect'); $I->see('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with not correct email'); $I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([ $contactPage->submit([
...@@ -28,11 +28,11 @@ $contactPage->submit([ ...@@ -28,11 +28,11 @@ $contactPage->submit([
'verifyCode' => 'testme', 'verifyCode' => 'testme',
]); ]);
$I->expectTo('see that email adress is wrong'); $I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline'); $I->dontSee('Name cannot be blank', '.help-block');
$I->see('Email is not a valid email address.'); $I->see('Email is not a valid email address.', '.help-block');
$I->dontSee('Subject cannot be blank', '.help-inline'); $I->dontSee('Subject cannot be blank', '.help-block');
$I->dontSee('Body cannot be blank', '.help-inline'); $I->dontSee('Body cannot be blank', '.help-block');
$I->dontSee('The verification code is incorrect', '.help-inline'); $I->dontSee('The verification code is incorrect', '.help-block');
$I->amGoingTo('submit contact form with correct data'); $I->amGoingTo('submit contact form with correct data');
$contactPage->submit([ $contactPage->submit([
......
...@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I); ...@@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data'); $I->amGoingTo('submit login form with no data');
$loginPage->login('', ''); $loginPage->login('', '');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials'); $I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong'); $loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors'); $I->expectTo('see validations errors');
$I->see('Incorrect username or password.'); $I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials'); $I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0'); $loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged'); $I->expectTo('see that user is logged');
$I->see('Logout (erau)'); $I->see('Logout (erau)', 'ul.nav li a');
$I->dontSee('Login'); $I->dontSee('Login', 'ul.nav li a');
$I->dontSee('Signup'); $I->dontSee('Signup', 'ul.nav li a');
$I->click('Logout (erau)');
$I->dontSee('Logout (erau)');
$I->see('Login');
...@@ -9,7 +9,7 @@ class SignupCest ...@@ -9,7 +9,7 @@ class SignupCest
{ {
/** /**
* This method is called after each cest class test method * This method is called before each cest class test method
* @param \Codeception\Event\Test $event * @param \Codeception\Event\Test $event
*/ */
public function _before($event) public function _before($event)
...@@ -34,6 +34,7 @@ class SignupCest ...@@ -34,6 +34,7 @@ class SignupCest
*/ */
public function _fail($event) public function _fail($event)
{ {
} }
/** /**
...@@ -46,6 +47,7 @@ class SignupCest ...@@ -46,6 +47,7 @@ class SignupCest
$I->wantTo('ensure that signup works'); $I->wantTo('ensure that signup works');
$signupPage = SignupPage::openBy($I); $signupPage = SignupPage::openBy($I);
$I->see('Signup', 'h1');
$I->see('Please fill out the following fields to signup:'); $I->see('Please fill out the following fields to signup:');
$I->amGoingTo('submit signup form with no data'); $I->amGoingTo('submit signup form with no data');
...@@ -53,9 +55,9 @@ class SignupCest ...@@ -53,9 +55,9 @@ class SignupCest
$signupPage->submit([]); $signupPage->submit([]);
$I->expectTo('see validation errors'); $I->expectTo('see validation errors');
$I->see('Username cannot be blank.'); $I->see('Username cannot be blank.', '.help-block');
$I->see('Email cannot be blank.'); $I->see('Email cannot be blank.', '.help-block');
$I->see('Password cannot be blank.'); $I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('submit signup form with not correct email'); $I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([ $signupPage->submit([
...@@ -64,9 +66,9 @@ class SignupCest ...@@ -64,9 +66,9 @@ class SignupCest
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that email adress is wrong'); $I->expectTo('see that email address is wrong');
$I->dontSee('Username cannot be blank.', '.help-inline'); $I->dontSee('Username cannot be blank.', '.help-block');
$I->dontSee('Password cannot be blank.', '.help-inline'); $I->dontSee('Password cannot be blank.', '.help-block');
$I->see('Email is not a valid email address.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block');
$I->amGoingTo('submit signup form with correct email'); $I->amGoingTo('submit signup form with correct email');
...@@ -76,7 +78,13 @@ class SignupCest ...@@ -76,7 +78,13 @@ class SignupCest
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that user is created');
$I->seeRecord('common\models\User', [
'username' => 'tester',
'email' => 'tester.email@example.com',
]);
$I->expectTo('see that user logged in'); $I->expectTo('see that user logged in');
$I->see('Logout (tester)'); $I->see('Logout (tester)', 'ul.nav li a');
} }
} }
...@@ -4,6 +4,7 @@ namespace frontend\tests\unit\models; ...@@ -4,6 +4,7 @@ namespace frontend\tests\unit\models;
use Yii; use Yii;
use frontend\tests\unit\TestCase; use frontend\tests\unit\TestCase;
use frontend\models\ContactForm;
class ContactFormTest extends TestCase class ContactFormTest extends TestCase
{ {
...@@ -26,8 +27,7 @@ class ContactFormTest extends TestCase ...@@ -26,8 +27,7 @@ class ContactFormTest extends TestCase
public function testContact() public function testContact()
{ {
$model = $this->getMock('frontend\models\ContactForm', ['validate']); $model = new ContactForm();
$model->expects($this->once())->method('validate')->will($this->returnValue(true));
$model->attributes = [ $model->attributes = [
'name' => 'Tester', 'name' => 'Tester',
...@@ -36,7 +36,7 @@ class ContactFormTest extends TestCase ...@@ -36,7 +36,7 @@ class ContactFormTest extends TestCase
'body' => 'body of current message', 'body' => 'body of current message',
]; ];
$model->contact('admin@example.com'); $model->sendEmail('admin@example.com');
$this->specify('email should be send', function () { $this->specify('email should be send', function () {
expect('email file should exist', file_exists($this->getMessageFile()))->true(); expect('email file should exist', file_exists($this->getMessageFile()))->true();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment