mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 23:50:38 +08:00
Codeception test adjustments for basic and advanced applications
- Moved everything test-related into `tests` directory. Codeception tests are in `codeception`. - Removed database module since we're using fixtures and migrations. - Moved console entry points and bootstrap into `tests/codeception/bin`. - Adjusted travis build scripts. - Adjusted documentation to be consistent and reflect changes made.
This commit is contained in:
8
apps/basic/tests/codeception/acceptance/AboutCept.php
Normal file
8
apps/basic/tests/codeception/acceptance/AboutCept.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use codeception\_pages\AboutPage;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that about works');
|
||||
AboutPage::openBy($I);
|
||||
$I->see('About', 'h1');
|
||||
49
apps/basic/tests/codeception/acceptance/ContactCept.php
Normal file
49
apps/basic/tests/codeception/acceptance/ContactCept.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use codeception\_pages\ContactPage;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that contact works');
|
||||
|
||||
$contactPage = ContactPage::openBy($I);
|
||||
|
||||
$I->see('Contact', 'h1');
|
||||
|
||||
$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->amGoingTo('submit contact form with not correct email');
|
||||
$contactPage->submit([
|
||||
'name' => 'tester',
|
||||
'email' => 'tester.email',
|
||||
'subject' => 'test subject',
|
||||
'body' => 'test content',
|
||||
'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->amGoingTo('submit contact form with correct data');
|
||||
$contactPage->submit([
|
||||
'name' => 'tester',
|
||||
'email' => 'tester@example.com',
|
||||
'subject' => 'test subject',
|
||||
'body' => 'test content',
|
||||
'verifyCode' => 'testme',
|
||||
]);
|
||||
if (method_exists($I, 'wait')) {
|
||||
$I->wait(3); // only for selenium
|
||||
}
|
||||
$I->dontSeeElement('#contact-form');
|
||||
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
||||
9
apps/basic/tests/codeception/acceptance/HomeCept.php
Normal file
9
apps/basic/tests/codeception/acceptance/HomeCept.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that home page works');
|
||||
$I->amOnPage(Yii::$app->homeUrl);
|
||||
$I->see('My Company');
|
||||
$I->seeLink('About');
|
||||
$I->click('About');
|
||||
$I->see('This is the About page.');
|
||||
32
apps/basic/tests/codeception/acceptance/LoginCept.php
Normal file
32
apps/basic/tests/codeception/acceptance/LoginCept.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use codeception\_pages\LoginPage;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that login works');
|
||||
|
||||
$loginPage = LoginPage::openBy($I);
|
||||
|
||||
$I->see('Login', 'h1');
|
||||
|
||||
$I->amGoingTo('try to login with empty credentials');
|
||||
$loginPage->login('', '');
|
||||
$I->expectTo('see validations errors');
|
||||
$I->see('Username cannot be blank.');
|
||||
$I->see('Password cannot be blank.');
|
||||
|
||||
$I->amGoingTo('try to login with wrong credentials');
|
||||
$loginPage->login('admin', 'wrong');
|
||||
if (method_exists($I, 'wait')) {
|
||||
$I->wait(3); // only for selenium
|
||||
}
|
||||
$I->expectTo('see validations errors');
|
||||
$I->see('Incorrect username or password.');
|
||||
|
||||
$I->amGoingTo('try to login with correct credentials');
|
||||
$loginPage->login('admin', 'admin');
|
||||
if (method_exists($I, 'wait')) {
|
||||
$I->wait(3); // only for selenium
|
||||
}
|
||||
$I->expectTo('see user info');
|
||||
$I->see('Logout (admin)');
|
||||
3
apps/basic/tests/codeception/acceptance/_bootstrap.php
Normal file
3
apps/basic/tests/codeception/acceptance/_bootstrap.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
new yii\web\Application(require(__DIR__ . '/_config.php'));
|
||||
13
apps/basic/tests/codeception/acceptance/_config.php
Normal file
13
apps/basic/tests/codeception/acceptance/_config.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../../config/web.php'),
|
||||
require(__DIR__ . '/../_config.php'),
|
||||
[
|
||||
'components' => [
|
||||
'db' => [
|
||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
Reference in New Issue
Block a user