Browse Source

Merge branch 'master' of github.com:yiisoft/yii2

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
0019f130cb
  1. 20
      apps/advanced/backend/tests/acceptance/LoginCept.php
  2. 15
      apps/advanced/backend/tests/functional/LoginCept.php
  3. 20
      apps/advanced/frontend/tests/acceptance/ContactCept.php
  4. 20
      apps/advanced/frontend/tests/acceptance/LoginCept.php
  5. 18
      apps/advanced/frontend/tests/acceptance/SignupCest.php
  6. 20
      apps/advanced/frontend/tests/functional/ContactCept.php
  7. 15
      apps/advanced/frontend/tests/functional/LoginCept.php
  8. 26
      apps/advanced/frontend/tests/functional/SignupCest.php
  9. 6
      apps/advanced/frontend/tests/unit/models/ContactFormTest.php

20
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');
*/

15
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');

20
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([

20
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');
*/

18
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)');
}
}

20
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([

15
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');

26
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)');
}
}

6
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();

Loading…
Cancel
Save