Commit cef430af by Alexander Makarov

Renamed guy classes to actors, fixed phpdoc and code style

parent 1bf6843d
# these files are auto generated by codeception build # these files are auto generated by codeception build
/unit/CodeGuy.php /unit/UnitTester.php
/functional/TestGuy.php /functional/FunctionalTester.php
/acceptance/WebGuy.php /acceptance/AcceptanceTester.php
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: WebGuy class_name: AcceptanceTester
modules: modules:
enabled: enabled:
- PhpBrowser - PhpBrowser
......
<?php <?php
use codeception_backend\WebGuy; use codeception_backend\AcceptanceTester;
use codeception\common\_pages\LoginPage; use codeception\common\_pages\LoginPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure login page works'); $I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php #basic/web/index.php
class_name: TestGuy class_name: FunctionalTester
modules: modules:
enabled: enabled:
- Filesystem - Filesystem
......
<?php <?php
use codeception_backend\TestGuy; use codeception_backend\FunctionalTester;
use codeception\common\_pages\LoginPage; use codeception\common\_pages\LoginPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure login page works'); $I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# suite for unit (internal) tests. # suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy class_name: UnitTester
# these files are auto generated by codeception build # these files are auto generated by codeception build
/unit/CodeGuy.php /unit/UnitTester.php
/functional/TestGuy.php /functional/FunctionalTester.php
/acceptance/WebGuy.php /acceptance/AcceptanceTester.php
...@@ -4,6 +4,10 @@ namespace codeception\common\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\common\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents loging page
* @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester|\codeception_backend\AcceptanceTester|\codeception_backend\FunctionalTester $actor
*/
class LoginPage extends BasePage class LoginPage extends BasePage
{ {
public $route = 'site/login'; public $route = 'site/login';
...@@ -14,8 +18,8 @@ class LoginPage extends BasePage ...@@ -14,8 +18,8 @@ class LoginPage extends BasePage
*/ */
public function login($username, $password) public function login($username, $password)
{ {
$this->guy->fillField('input[name="LoginForm[username]"]', $username); $this->actor->fillField('input[name="LoginForm[username]"]', $username);
$this->guy->fillField('input[name="LoginForm[password]"]', $password); $this->actor->fillField('input[name="LoginForm[password]"]', $password);
$this->guy->click('login-button'); $this->actor->click('login-button');
} }
} }
...@@ -16,7 +16,7 @@ class FixtureHelper extends Module ...@@ -16,7 +16,7 @@ class FixtureHelper extends Module
/** /**
* Redeclare visibility because codeception includes all public methods that not starts from "_" * Redeclare visibility because codeception includes all public methods that not starts from "_"
* and not excluded by module settings, in guy class. * and not excluded by module settings, in actor class.
*/ */
use FixtureTrait { use FixtureTrait {
loadFixtures as protected; loadFixtures as protected;
...@@ -52,7 +52,7 @@ class FixtureHelper extends Module ...@@ -52,7 +52,7 @@ class FixtureHelper extends Module
{ {
return [ return [
'user' => [ 'user' => [
'class' => UserFixture::className(), 'class' => UserFixture::className(),
'dataFile' => '@codeception/common/fixtures/data/init_login.php', 'dataFile' => '@codeception/common/fixtures/data/init_login.php',
], ],
]; ];
......
...@@ -4,6 +4,9 @@ namespace codeception\common\fixtures; ...@@ -4,6 +4,9 @@ namespace codeception\common\fixtures;
use yii\test\ActiveFixture; use yii\test\ActiveFixture;
/**
* User fixture
*/
class UserFixture extends ActiveFixture class UserFixture extends ActiveFixture
{ {
public $modelClass = 'common\models\User'; public $modelClass = 'common\models\User';
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# suite for unit (internal) tests. # suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy class_name: UnitTester
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace codeception\common\unit; namespace codeception\common\unit;
/**
* @inheritdoc
*/
class DbTestCase extends \yii\codeception\DbTestCase class DbTestCase extends \yii\codeception\DbTestCase
{ {
public $appConfig = '@codeception/common/unit/_config.php'; public $appConfig = '@codeception/common/unit/_config.php';
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace common\tests\unit; namespace common\tests\unit;
/**
* @inheritdoc
*/
class TestCase extends \yii\codeception\TestCase class TestCase extends \yii\codeception\TestCase
{ {
public $appConfig = '@common/tests/unit/_config.php'; public $appConfig = '@common/tests/unit/_config.php';
......
...@@ -8,6 +8,9 @@ use Codeception\Specify; ...@@ -8,6 +8,9 @@ use Codeception\Specify;
use common\models\LoginForm; use common\models\LoginForm;
use codeception\common\fixtures\UserFixture; use codeception\common\fixtures\UserFixture;
/**
* Login form test
*/
class LoginFormTest extends DbTestCase class LoginFormTest extends DbTestCase
{ {
...@@ -75,6 +78,9 @@ class LoginFormTest extends DbTestCase ...@@ -75,6 +78,9 @@ class LoginFormTest extends DbTestCase
}); });
} }
/**
* @inheritdoc
*/
public function fixtures() public function fixtures()
{ {
return [ return [
......
# these files are auto generated by codeception build # these files are auto generated by codeception build
/unit/CodeGuy.php /unit/UnitTester.php
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# suite for unit (internal) tests. # suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy class_name: UnitTester
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace console\tests\unit; namespace console\tests\unit;
/**
* @inheritdoc
*/
class DbTestCase extends \yii\codeception\DbTestCase class DbTestCase extends \yii\codeception\DbTestCase
{ {
public $appConfig = '@console/tests/unit/_config.php'; public $appConfig = '@console/tests/unit/_config.php';
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace console\tests\unit; namespace console\tests\unit;
/**
* @inheritdoc
*/
class TestCase extends \yii\codeception\TestCase class TestCase extends \yii\codeception\TestCase
{ {
public $appConfig = '@console/tests/unit/_config.php'; public $appConfig = '@console/tests/unit/_config.php';
......
# these files are auto generated by codeception build # these files are auto generated by codeception build
/unit/CodeGuy.php /unit/UnitTester.php
/functional/TestGuy.php /functional/FunctionalTester.php
/acceptance/WebGuy.php /acceptance/AcceptanceTester.php
...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents about page
* @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
*/
class AboutPage extends BasePage class AboutPage extends BasePage
{ {
public $route = 'site/about'; public $route = 'site/about';
......
...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents contact page
* @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
*/
class ContactPage extends BasePage class ContactPage extends BasePage
{ {
public $route = 'site/contact'; public $route = 'site/contact';
...@@ -15,8 +19,8 @@ class ContactPage extends BasePage ...@@ -15,8 +19,8 @@ class ContactPage extends BasePage
{ {
foreach ($contactData as $field => $value) { foreach ($contactData as $field => $value) {
$inputType = $field === 'body' ? 'textarea' : 'input'; $inputType = $field === 'body' ? 'textarea' : 'input';
$this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
} }
$this->guy->click('contact-button'); $this->actor->click('contact-button');
} }
} }
...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\frontend\_pages;
use \yii\codeception\BasePage; use \yii\codeception\BasePage;
/**
* Represents signup page
* @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
*/
class SignupPage extends BasePage class SignupPage extends BasePage
{ {
...@@ -16,8 +20,8 @@ class SignupPage extends BasePage ...@@ -16,8 +20,8 @@ class SignupPage extends BasePage
{ {
foreach ($signupData as $field => $value) { foreach ($signupData as $field => $value) {
$inputType = $field === 'body' ? 'textarea' : 'input'; $inputType = $field === 'body' ? 'textarea' : 'input';
$this->guy->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value); $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value);
} }
$this->guy->click('signup-button'); $this->actor->click('signup-button');
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: WebGuy class_name: AcceptanceTester
modules: modules:
enabled: enabled:
- PhpBrowser - PhpBrowser
......
<?php <?php
use codeception_frontend\WebGuy; use codeception_frontend\AcceptanceTester;
use codeception\frontend\_pages\AboutPage; use codeception\frontend\_pages\AboutPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that about works'); $I->wantTo('ensure that about works');
AboutPage::openBy($I); AboutPage::openBy($I);
$I->see('About', 'h1'); $I->see('About', 'h1');
<?php <?php
use codeception_frontend\WebGuy; use codeception_frontend\AcceptanceTester;
use codeception\frontend\_pages\ContactPage; use codeception\frontend\_pages\ContactPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that contact works'); $I->wantTo('ensure that contact works');
$contactPage = ContactPage::openBy($I); $contactPage = ContactPage::openBy($I);
...@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect', '.help-block'); ...@@ -21,11 +21,11 @@ $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([
'name' => 'tester', 'name' => 'tester',
'email' => 'tester.email', 'email' => 'tester.email',
'subject' => 'test subject', 'subject' => 'test subject',
'body' => 'test content', 'body' => 'test content',
'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-block'); $I->dontSee('Name cannot be blank', '.help-block');
...@@ -36,10 +36,10 @@ $I->dontSee('The verification code is incorrect', '.help-block'); ...@@ -36,10 +36,10 @@ $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([
'name' => 'tester', 'name' => 'tester',
'email' => 'tester@example.com', 'email' => 'tester@example.com',
'subject' => 'test subject', 'subject' => 'test subject',
'body' => 'test content', 'body' => 'test content',
'verifyCode' => 'testme', 'verifyCode' => 'testme',
]); ]);
$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
<?php <?php
use codeception_frontend\WebGuy; use codeception_frontend\AcceptanceTester;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that home page works'); $I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl); $I->amOnPage(Yii::$app->homeUrl);
$I->see('My Company'); $I->see('My Company');
......
<?php <?php
use codeception_frontend\WebGuy; use codeception_frontend\AcceptanceTester;
use codeception\common\_pages\LoginPage; use codeception\common\_pages\LoginPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure login page works'); $I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -10,7 +10,7 @@ class SignupCest ...@@ -10,7 +10,7 @@ class SignupCest
/** /**
* This method is called before each cest class test method * This method is called before each cest class test method
* @param \Codeception\Event\Test $event * @param \Codeception\Event\TestEvent $event
*/ */
public function _before($event) public function _before($event)
{ {
...@@ -18,7 +18,7 @@ class SignupCest ...@@ -18,7 +18,7 @@ class SignupCest
/** /**
* This method is called after each cest class test method, even if test failed. * This method is called after each cest class test method, even if test failed.
* @param \Codeception\Event\Test $event * @param \Codeception\Event\TestEvent $event
*/ */
public function _after($event) public function _after($event)
{ {
...@@ -30,14 +30,14 @@ class SignupCest ...@@ -30,14 +30,14 @@ class SignupCest
/** /**
* This method is called when test fails. * This method is called when test fails.
* @param \Codeception\Event\Fail $event * @param \Codeception\Event\FailEvent $event
*/ */
public function _fail($event) public function _fail($event)
{ {
} }
/** /**
* @param \WebGuy $I * @param \codeception_frontend\AcceptanceTester $I
* @param \Codeception\Scenario $scenario * @param \Codeception\Scenario $scenario
*/ */
public function testUserSignup($I, $scenario) public function testUserSignup($I, $scenario)
...@@ -59,9 +59,9 @@ class SignupCest ...@@ -59,9 +59,9 @@ class SignupCest
$I->amGoingTo('submit signup form with not correct email'); $I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([ $signupPage->submit([
'username' => 'tester', 'username' => 'tester',
'email' => 'tester.email', 'email' => 'tester.email',
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that email address is wrong'); $I->expectTo('see that email address is wrong');
...@@ -71,9 +71,9 @@ class SignupCest ...@@ -71,9 +71,9 @@ class SignupCest
$I->amGoingTo('submit signup form with correct email'); $I->amGoingTo('submit signup form with correct email');
$signupPage->submit([ $signupPage->submit([
'username' => 'tester', 'username' => 'tester',
'email' => 'tester.email@example.com', 'email' => 'tester.email@example.com',
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that user logged in'); $I->expectTo('see that user logged in');
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php #basic/web/index.php
class_name: TestGuy class_name: FunctionalTester
modules: modules:
enabled: enabled:
- Filesystem - Filesystem
......
<?php <?php
use codeception_frontend\TestGuy; use codeception_frontend\FunctionalTester;
use codeception\frontend\_pages\AboutPage; use codeception\frontend\_pages\AboutPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that about works'); $I->wantTo('ensure that about works');
AboutPage::openBy($I); AboutPage::openBy($I);
$I->see('About', 'h1'); $I->see('About', 'h1');
<?php <?php
use codeception_frontend\TestGuy; use codeception_frontend\FunctionalTester;
use codeception\frontend\_pages\ContactPage; use codeception\frontend\_pages\ContactPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that contact works'); $I->wantTo('ensure that contact works');
$contactPage = ContactPage::openBy($I); $contactPage = ContactPage::openBy($I);
...@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect', '.help-block'); ...@@ -21,11 +21,11 @@ $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([
'name' => 'tester', 'name' => 'tester',
'email' => 'tester.email', 'email' => 'tester.email',
'subject' => 'test subject', 'subject' => 'test subject',
'body' => 'test content', 'body' => 'test content',
'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-block'); $I->dontSee('Name cannot be blank', '.help-block');
...@@ -36,10 +36,10 @@ $I->dontSee('The verification code is incorrect', '.help-block'); ...@@ -36,10 +36,10 @@ $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([
'name' => 'tester', 'name' => 'tester',
'email' => 'tester@example.com', 'email' => 'tester@example.com',
'subject' => 'test subject', 'subject' => 'test subject',
'body' => 'test content', 'body' => 'test content',
'verifyCode' => 'testme', 'verifyCode' => 'testme',
]); ]);
$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); $I->see('Thank you for contacting us. We will respond to you as soon as possible.');
<?php <?php
use codeception_frontend\TestGuy; use codeception_frontend\FunctionalTester;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works'); $I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl); $I->amOnPage(Yii::$app->homeUrl);
$I->see('My Company'); $I->see('My Company');
......
<?php <?php
use codeception_frontend\TestGuy; use codeception_frontend\FunctionalTester;
use codeception\common\_pages\LoginPage; use codeception\common\_pages\LoginPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure login page works'); $I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -10,7 +10,7 @@ class SignupCest ...@@ -10,7 +10,7 @@ class SignupCest
/** /**
* This method is called before each cest class test method * This method is called before each cest class test method
* @param \Codeception\Event\Test $event * @param \Codeception\Event\TestEvent $event
*/ */
public function _before($event) public function _before($event)
{ {
...@@ -18,7 +18,7 @@ class SignupCest ...@@ -18,7 +18,7 @@ class SignupCest
/** /**
* This method is called after each cest class test method, even if test failed. * This method is called after each cest class test method, even if test failed.
* @param \Codeception\Event\Test $event * @param \Codeception\Event\TestEvent $event
*/ */
public function _after($event) public function _after($event)
{ {
...@@ -30,7 +30,7 @@ class SignupCest ...@@ -30,7 +30,7 @@ class SignupCest
/** /**
* This method is called when test fails. * This method is called when test fails.
* @param \Codeception\Event\Fail $event * @param \Codeception\Event\FailEvent $event
*/ */
public function _fail($event) public function _fail($event)
{ {
...@@ -39,7 +39,7 @@ class SignupCest ...@@ -39,7 +39,7 @@ class SignupCest
/** /**
* *
* @param \TestGuy $I * @param \codeception_frontend\FunctionalTester $I
* @param \Codeception\Scenario $scenario * @param \Codeception\Scenario $scenario
*/ */
public function testUserSignup($I, $scenario) public function testUserSignup($I, $scenario)
...@@ -61,9 +61,9 @@ class SignupCest ...@@ -61,9 +61,9 @@ class SignupCest
$I->amGoingTo('submit signup form with not correct email'); $I->amGoingTo('submit signup form with not correct email');
$signupPage->submit([ $signupPage->submit([
'username' => 'tester', 'username' => 'tester',
'email' => 'tester.email', 'email' => 'tester.email',
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that email address is wrong'); $I->expectTo('see that email address is wrong');
...@@ -73,15 +73,15 @@ class SignupCest ...@@ -73,15 +73,15 @@ class SignupCest
$I->amGoingTo('submit signup form with correct email'); $I->amGoingTo('submit signup form with correct email');
$signupPage->submit([ $signupPage->submit([
'username' => 'tester', 'username' => 'tester',
'email' => 'tester.email@example.com', 'email' => 'tester.email@example.com',
'password' => 'tester_password', 'password' => 'tester_password',
]); ]);
$I->expectTo('see that user is created'); $I->expectTo('see that user is created');
$I->seeRecord('common\models\User', [ $I->seeRecord('common\models\User', [
'username' => 'tester', 'username' => 'tester',
'email' => 'tester.email@example.com', 'email' => 'tester.email@example.com',
]); ]);
$I->expectTo('see that user logged in'); $I->expectTo('see that user logged in');
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# suite for unit (internal) tests. # suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy class_name: UnitTester
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace codeception\frontend\unit; namespace codeception\frontend\unit;
/**
* @inheritdoc
*/
class DbTestCase extends \yii\codeception\DbTestCase class DbTestCase extends \yii\codeception\DbTestCase
{ {
public $appConfig = '@codeception/frontend/unit/_config.php'; public $appConfig = '@codeception/frontend/unit/_config.php';
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace codeception\frontend\unit; namespace codeception\frontend\unit;
/**
* @inheritdoc
*/
class TestCase extends \yii\codeception\TestCase class TestCase extends \yii\codeception\TestCase
{ {
public $appConfig = '@codeception/frontend/unit/_config.php'; public $appConfig = '@codeception/frontend/unit/_config.php';
......
# these files are auto generated by codeception build # these files are auto generated by codeception build
/unit/CodeGuy.php /unit/UnitTester.php
/functional/TestGuy.php /functional/FunctionalTester.php
/acceptance/WebGuy.php /acceptance/AcceptanceTester.php
...@@ -4,6 +4,10 @@ namespace codeception\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents about page
* @property \AcceptanceTester|\FunctionalTester $actor
*/
class AboutPage extends BasePage class AboutPage extends BasePage
{ {
public $route = 'site/about'; public $route = 'site/about';
......
...@@ -4,6 +4,10 @@ namespace codeception\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents contact page
* @property \AcceptanceTester|\FunctionalTester $actor
*/
class ContactPage extends BasePage class ContactPage extends BasePage
{ {
public $route = 'site/contact'; public $route = 'site/contact';
...@@ -15,8 +19,8 @@ class ContactPage extends BasePage ...@@ -15,8 +19,8 @@ class ContactPage extends BasePage
{ {
foreach ($contactData as $field => $value) { foreach ($contactData as $field => $value) {
$inputType = $field === 'body' ? 'textarea' : 'input'; $inputType = $field === 'body' ? 'textarea' : 'input';
$this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
} }
$this->guy->click('contact-button'); $this->actor->click('contact-button');
} }
} }
...@@ -4,6 +4,10 @@ namespace codeception\_pages; ...@@ -4,6 +4,10 @@ namespace codeception\_pages;
use yii\codeception\BasePage; use yii\codeception\BasePage;
/**
* Represents login page
* @property \AcceptanceTester|\FunctionalTester $actor
*/
class LoginPage extends BasePage class LoginPage extends BasePage
{ {
public $route = 'site/login'; public $route = 'site/login';
...@@ -14,8 +18,8 @@ class LoginPage extends BasePage ...@@ -14,8 +18,8 @@ class LoginPage extends BasePage
*/ */
public function login($username, $password) public function login($username, $password)
{ {
$this->guy->fillField('input[name="LoginForm[username]"]', $username); $this->actor->fillField('input[name="LoginForm[username]"]', $username);
$this->guy->fillField('input[name="LoginForm[password]"]', $password); $this->actor->fillField('input[name="LoginForm[password]"]', $password);
$this->guy->click('login-button'); $this->actor->click('login-button');
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: WebGuy class_name: AcceptanceTester
modules: modules:
enabled: enabled:
- PhpBrowser - PhpBrowser
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\AboutPage; use codeception\_pages\AboutPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that about works'); $I->wantTo('ensure that about works');
AboutPage::openBy($I); AboutPage::openBy($I);
$I->see('About', 'h1'); $I->see('About', 'h1');
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\ContactPage; use codeception\_pages\ContactPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that contact works'); $I->wantTo('ensure that contact works');
$contactPage = ContactPage::openBy($I); $contactPage = ContactPage::openBy($I);
......
<?php <?php
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that home page works'); $I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl); $I->amOnPage(Yii::$app->homeUrl);
$I->see('My Company'); $I->see('My Company');
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\LoginPage; use codeception\_pages\LoginPage;
$I = new WebGuy($scenario); $I = new AcceptanceTester($scenario);
$I->wantTo('ensure that login works'); $I->wantTo('ensure that login works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php #basic/web/index.php
class_name: TestGuy class_name: FunctionalTester
modules: modules:
enabled: enabled:
- Filesystem - Filesystem
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\AboutPage; use codeception\_pages\AboutPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that about works'); $I->wantTo('ensure that about works');
AboutPage::openBy($I); AboutPage::openBy($I);
$I->see('About', 'h1'); $I->see('About', 'h1');
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\ContactPage; use codeception\_pages\ContactPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that contact works'); $I->wantTo('ensure that contact works');
$contactPage = ContactPage::openBy($I); $contactPage = ContactPage::openBy($I);
......
<?php <?php
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that home page works'); $I->wantTo('ensure that home page works');
$I->amOnPage(Yii::$app->homeUrl); $I->amOnPage(Yii::$app->homeUrl);
$I->see('My Company'); $I->see('My Company');
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use codeception\_pages\LoginPage; use codeception\_pages\LoginPage;
$I = new TestGuy($scenario); $I = new FunctionalTester($scenario);
$I->wantTo('ensure that login works'); $I->wantTo('ensure that login works');
$loginPage = LoginPage::openBy($I); $loginPage = LoginPage::openBy($I);
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
# suite for unit (internal) tests. # suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy class_name: UnitTester
...@@ -29,19 +29,19 @@ abstract class BasePage extends Component ...@@ -29,19 +29,19 @@ abstract class BasePage extends Component
public $route; public $route;
/** /**
* @var \Codeception\AbstractGuy the testing guy object * @var \Codeception\Actor the testing guy object
*/ */
protected $guy; protected $actor;
/** /**
* Constructor. * Constructor.
* *
* @param \Codeception\AbstractGuy $I the testing guy object * @param \Codeception\Actor $I the testing guy object
*/ */
public function __construct($I) public function __construct($I)
{ {
$this->guy = $I; $this->actor = $I;
} }
/** /**
...@@ -67,7 +67,7 @@ abstract class BasePage extends Component ...@@ -67,7 +67,7 @@ abstract class BasePage extends Component
/** /**
* Creates a page instance and sets the test guy to use [[url]]. * Creates a page instance and sets the test guy to use [[url]].
* @param \Codeception\AbstractGuy $I the test guy instance * @param \Codeception\Actor $I the test guy instance
* @param array $params the GET parameters to be used to generate [[url]] * @param array $params the GET parameters to be used to generate [[url]]
* @return static the page instance * @return static the page instance
*/ */
......
...@@ -10,6 +10,8 @@ namespace yii\codeception; ...@@ -10,6 +10,8 @@ namespace yii\codeception;
use yii\test\InitDbFixture; use yii\test\InitDbFixture;
/** /**
* Base class for database test cases
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
......
...@@ -52,11 +52,11 @@ If you want to use codeception modules and helpers in your unit tests, you can d ...@@ -52,11 +52,11 @@ If you want to use codeception modules and helpers in your unit tests, you can d
$this->getModule('CodeHelper'); #or some other module $this->getModule('CodeHelper'); #or some other module
``` ```
You also can use all guy methods by accessing guy instance like: You also can use all actor methods by accessing actor instance like:
```php ```php
<?php <?php
$this->codeGuy->someMethodFromModule(); $this->unitTester->someMethodFromModule();
``` ```
Codeception events Codeception events
------------------ ------------------
......
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