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