diff --git a/apps/advanced/backend/tests/acceptance/LoginCept.php b/apps/advanced/backend/tests/acceptance/LoginCept.php index 62ebc0e..fddcf87 100644 --- a/apps/advanced/backend/tests/acceptance/LoginCept.php +++ b/apps/advanced/backend/tests/acceptance/LoginCept.php @@ -10,21 +10,23 @@ $loginPage = LoginPage::openBy($I); $I->amGoingTo('submit login form with no data'); $loginPage->login('', ''); $I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); +$I->see('Username cannot be blank.', '.help-block'); +$I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('try to login with wrong credentials'); $I->expectTo('see validations errors'); $loginPage->login('admin', 'wrong'); $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'); $loginPage->login('erau', 'password_0'); $I->expectTo('see that user is logged'); -$I->see('Logout (erau)'); -$I->dontSee('Login'); -$I->dontSee('Signup'); -$I->click('Logout (erau)'); -$I->dontSee('Logout (erau)'); -$I->see('Login'); +$I->seeLink('Logout (erau)'); +$I->dontSeeLink('Login'); +$I->dontSeeLink('Signup'); +/** Uncomment if using WebDriver + * $I->click('Logout (erau)'); + * $I->dontSeeLink('Logout (erau)'); + * $I->seeLink('Login'); + */ diff --git a/apps/advanced/backend/tests/functional/LoginCept.php b/apps/advanced/backend/tests/functional/LoginCept.php index 1d2dc14..3c347b7 100644 --- a/apps/advanced/backend/tests/functional/LoginCept.php +++ b/apps/advanced/backend/tests/functional/LoginCept.php @@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I); $I->amGoingTo('submit login form with no data'); $loginPage->login('', ''); $I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); +$I->see('Username cannot be blank.', '.help-block'); +$I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('try to login with wrong credentials'); $I->expectTo('see validations errors'); $loginPage->login('admin', 'wrong'); $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'); $loginPage->login('erau', 'password_0'); $I->expectTo('see that user is logged'); -$I->see('Logout (erau)'); -$I->dontSee('Login'); -$I->dontSee('Signup'); -$I->click('Logout (erau)'); -$I->dontSee('Logout (erau)'); -$I->see('Login'); +$I->seeLink('Logout (erau)'); +$I->dontSeeLink('Login'); +$I->dontSeeLink('Signup'); diff --git a/apps/advanced/frontend/tests/acceptance/ContactCept.php b/apps/advanced/frontend/tests/acceptance/ContactCept.php index 84c2911..6351cb6 100644 --- a/apps/advanced/frontend/tests/acceptance/ContactCept.php +++ b/apps/advanced/frontend/tests/acceptance/ContactCept.php @@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data'); $contactPage->submit([]); $I->expectTo('see validations errors'); $I->see('Contact', 'h1'); -$I->see('Name cannot be blank'); -$I->see('Email cannot be blank'); -$I->see('Subject cannot be blank'); -$I->see('Body cannot be blank'); -$I->see('The verification code is incorrect'); +$I->see('Name cannot be blank', '.help-block'); +$I->see('Email cannot be blank', '.help-block'); +$I->see('Subject cannot be blank', '.help-block'); +$I->see('Body cannot be blank', '.help-block'); +$I->see('The verification code is incorrect', '.help-block'); $I->amGoingTo('submit contact form with not correct email'); $contactPage->submit([ @@ -28,11 +28,11 @@ $contactPage->submit([ 'verifyCode' => 'testme', ]); $I->expectTo('see that email adress is wrong'); -$I->dontSee('Name cannot be blank', '.help-inline'); -$I->see('Email is not a valid email address.'); -$I->dontSee('Subject cannot be blank', '.help-inline'); -$I->dontSee('Body cannot be blank', '.help-inline'); -$I->dontSee('The verification code is incorrect', '.help-inline'); +$I->dontSee('Name cannot be blank', '.help-block'); +$I->see('Email is not a valid email address.', '.help-block'); +$I->dontSee('Subject cannot be blank', '.help-block'); +$I->dontSee('Body cannot be blank', '.help-block'); +$I->dontSee('The verification code is incorrect', '.help-block'); $I->amGoingTo('submit contact form with correct data'); $contactPage->submit([ diff --git a/apps/advanced/frontend/tests/acceptance/LoginCept.php b/apps/advanced/frontend/tests/acceptance/LoginCept.php index 62ebc0e..fddcf87 100644 --- a/apps/advanced/frontend/tests/acceptance/LoginCept.php +++ b/apps/advanced/frontend/tests/acceptance/LoginCept.php @@ -10,21 +10,23 @@ $loginPage = LoginPage::openBy($I); $I->amGoingTo('submit login form with no data'); $loginPage->login('', ''); $I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); +$I->see('Username cannot be blank.', '.help-block'); +$I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('try to login with wrong credentials'); $I->expectTo('see validations errors'); $loginPage->login('admin', 'wrong'); $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'); $loginPage->login('erau', 'password_0'); $I->expectTo('see that user is logged'); -$I->see('Logout (erau)'); -$I->dontSee('Login'); -$I->dontSee('Signup'); -$I->click('Logout (erau)'); -$I->dontSee('Logout (erau)'); -$I->see('Login'); +$I->seeLink('Logout (erau)'); +$I->dontSeeLink('Login'); +$I->dontSeeLink('Signup'); +/** Uncomment if using WebDriver + * $I->click('Logout (erau)'); + * $I->dontSeeLink('Logout (erau)'); + * $I->seeLink('Login'); + */ diff --git a/apps/advanced/frontend/tests/acceptance/SignupCest.php b/apps/advanced/frontend/tests/acceptance/SignupCest.php index 268ff6b..9de45d8 100644 --- a/apps/advanced/frontend/tests/acceptance/SignupCest.php +++ b/apps/advanced/frontend/tests/acceptance/SignupCest.php @@ -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 */ public function _before($event) @@ -37,7 +37,6 @@ class SignupCest } /** - * * @param \WebGuy $I * @param \Codeception\Scenario $scenario */ @@ -46,6 +45,7 @@ class SignupCest $I->wantTo('ensure that signup works'); $signupPage = SignupPage::openBy($I); + $I->see('Signup', 'h1'); $I->see('Please fill out the following fields to signup:'); $I->amGoingTo('submit signup form with no data'); @@ -53,9 +53,9 @@ class SignupCest $signupPage->submit([]); $I->expectTo('see validation errors'); - $I->see('Username cannot be blank.'); - $I->see('Email cannot be blank.'); - $I->see('Password cannot be blank.'); + $I->see('Username cannot be blank.', '.help-block'); + $I->see('Email cannot be blank.', '.help-block'); + $I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('submit signup form with not correct email'); $signupPage->submit([ @@ -64,9 +64,9 @@ class SignupCest 'password' => 'tester_password', ]); - $I->expectTo('see that email adress is wrong'); - $I->dontSee('Username cannot be blank.', '.help-inline'); - $I->dontSee('Password cannot be blank.', '.help-inline'); + $I->expectTo('see that email address is wrong'); + $I->dontSee('Username cannot be blank.', '.help-block'); + $I->dontSee('Password cannot be blank.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block'); $I->amGoingTo('submit signup form with correct email'); @@ -77,6 +77,6 @@ class SignupCest ]); $I->expectTo('see that user logged in'); - $I->see('Logout (tester)'); + $I->seeLink('Logout (tester)'); } } diff --git a/apps/advanced/frontend/tests/functional/ContactCept.php b/apps/advanced/frontend/tests/functional/ContactCept.php index 7fc1ddb..b29b72f 100644 --- a/apps/advanced/frontend/tests/functional/ContactCept.php +++ b/apps/advanced/frontend/tests/functional/ContactCept.php @@ -13,11 +13,11 @@ $I->amGoingTo('submit contact form with no data'); $contactPage->submit([]); $I->expectTo('see validations errors'); $I->see('Contact', 'h1'); -$I->see('Name cannot be blank'); -$I->see('Email cannot be blank'); -$I->see('Subject cannot be blank'); -$I->see('Body cannot be blank'); -$I->see('The verification code is incorrect'); +$I->see('Name cannot be blank', '.help-block'); +$I->see('Email cannot be blank', '.help-block'); +$I->see('Subject cannot be blank', '.help-block'); +$I->see('Body cannot be blank', '.help-block'); +$I->see('The verification code is incorrect', '.help-block'); $I->amGoingTo('submit contact form with not correct email'); $contactPage->submit([ @@ -28,11 +28,11 @@ $contactPage->submit([ 'verifyCode' => 'testme', ]); $I->expectTo('see that email adress is wrong'); -$I->dontSee('Name cannot be blank', '.help-inline'); -$I->see('Email is not a valid email address.'); -$I->dontSee('Subject cannot be blank', '.help-inline'); -$I->dontSee('Body cannot be blank', '.help-inline'); -$I->dontSee('The verification code is incorrect', '.help-inline'); +$I->dontSee('Name cannot be blank', '.help-block'); +$I->see('Email is not a valid email address.', '.help-block'); +$I->dontSee('Subject cannot be blank', '.help-block'); +$I->dontSee('Body cannot be blank', '.help-block'); +$I->dontSee('The verification code is incorrect', '.help-block'); $I->amGoingTo('submit contact form with correct data'); $contactPage->submit([ diff --git a/apps/advanced/frontend/tests/functional/LoginCept.php b/apps/advanced/frontend/tests/functional/LoginCept.php index 1d2dc14..3c347b7 100644 --- a/apps/advanced/frontend/tests/functional/LoginCept.php +++ b/apps/advanced/frontend/tests/functional/LoginCept.php @@ -10,21 +10,18 @@ $loginPage = LoginPage::openBy($I); $I->amGoingTo('submit login form with no data'); $loginPage->login('', ''); $I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); +$I->see('Username cannot be blank.', '.help-block'); +$I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('try to login with wrong credentials'); $I->expectTo('see validations errors'); $loginPage->login('admin', 'wrong'); $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'); $loginPage->login('erau', 'password_0'); $I->expectTo('see that user is logged'); -$I->see('Logout (erau)'); -$I->dontSee('Login'); -$I->dontSee('Signup'); -$I->click('Logout (erau)'); -$I->dontSee('Logout (erau)'); -$I->see('Login'); +$I->seeLink('Logout (erau)'); +$I->dontSeeLink('Login'); +$I->dontSeeLink('Signup'); diff --git a/apps/advanced/frontend/tests/functional/SignupCest.php b/apps/advanced/frontend/tests/functional/SignupCest.php index 0409d23..86efff4 100644 --- a/apps/advanced/frontend/tests/functional/SignupCest.php +++ b/apps/advanced/frontend/tests/functional/SignupCest.php @@ -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 */ public function _before($event) @@ -34,10 +34,11 @@ class SignupCest */ public function _fail($event) { + } /** - * + * * @param \TestGuy $I * @param \Codeception\Scenario $scenario */ @@ -46,6 +47,7 @@ class SignupCest $I->wantTo('ensure that signup works'); $signupPage = SignupPage::openBy($I); + $I->see('Signup', 'h1'); $I->see('Please fill out the following fields to signup:'); $I->amGoingTo('submit signup form with no data'); @@ -53,9 +55,9 @@ class SignupCest $signupPage->submit([]); $I->expectTo('see validation errors'); - $I->see('Username cannot be blank.'); - $I->see('Email cannot be blank.'); - $I->see('Password cannot be blank.'); + $I->see('Username cannot be blank.', '.help-block'); + $I->see('Email cannot be blank.', '.help-block'); + $I->see('Password cannot be blank.', '.help-block'); $I->amGoingTo('submit signup form with not correct email'); $signupPage->submit([ @@ -64,9 +66,9 @@ class SignupCest 'password' => 'tester_password', ]); - $I->expectTo('see that email adress is wrong'); - $I->dontSee('Username cannot be blank.', '.help-inline'); - $I->dontSee('Password cannot be blank.', '.help-inline'); + $I->expectTo('see that email address is wrong'); + $I->dontSee('Username cannot be blank.', '.help-block'); + $I->dontSee('Password cannot be blank.', '.help-block'); $I->see('Email is not a valid email address.', '.help-block'); $I->amGoingTo('submit signup form with correct email'); @@ -76,7 +78,13 @@ class SignupCest '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->see('Logout (tester)'); + $I->seeLink('Logout (tester)'); } } diff --git a/apps/advanced/frontend/tests/unit/models/ContactFormTest.php b/apps/advanced/frontend/tests/unit/models/ContactFormTest.php index a754672..28f1747 100644 --- a/apps/advanced/frontend/tests/unit/models/ContactFormTest.php +++ b/apps/advanced/frontend/tests/unit/models/ContactFormTest.php @@ -4,6 +4,7 @@ namespace frontend\tests\unit\models; use Yii; use frontend\tests\unit\TestCase; +use frontend\models\ContactForm; class ContactFormTest extends TestCase { @@ -26,8 +27,7 @@ class ContactFormTest extends TestCase public function testContact() { - $model = $this->getMock('frontend\models\ContactForm', ['validate']); - $model->expects($this->once())->method('validate')->will($this->returnValue(true)); + $model = new ContactForm(); $model->attributes = [ 'name' => 'Tester', @@ -36,7 +36,7 @@ class ContactFormTest extends TestCase 'body' => 'body of current message', ]; - $model->contact('admin@example.com'); + $model->sendEmail('admin@example.com'); $this->specify('email should be send', function () { expect('email file should exist', file_exists($this->getMessageFile()))->true();