Acceptance tests refactoring (#1)

This commit is contained in:
Maxim Shcherbakov 2016-07-14 19:20:28 +03:00 committed by Michael Bodnarchuk
parent 75a273eb40
commit aaee0841e1
11 changed files with 128 additions and 58 deletions

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -12,6 +12,8 @@ class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
# - Yii2:
# configFile: '/codeception/config/acceptance.php'
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/03-AcceptanceTests#selenium-webdriver
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,

View File

@ -1,10 +0,0 @@
<?php
use tests\codeception\_pages\AboutPage;
/* @var $scenario Codeception\Scenario */
$I = new AcceptanceTester($scenario);
$I->wantTo('ensure that about works');
AboutPage::openBy($I);
$I->see('About', 'h1');

View File

@ -0,0 +1,11 @@
<?php
class AboutCest
{
public function ensureThatAboutWorks(AcceptanceTester $I)
{
//$I->amOnPage(['site/about']);
$I->amOnPage('index.php?r=site%2Fabout');
$I->see('About', 'h1');
}
}

View File

@ -1,11 +0,0 @@
<?php
/* @var $scenario Codeception\Scenario */
$I = new AcceptanceTester($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.');

View File

@ -0,0 +1,16 @@
<?php
class HomeCest
{
public function ensureThatHomePageWorks(AcceptanceTester $I)
{
//$I->amOnPage(Yii::$app->homeUrl);
$I->amOnPage('index.php?r=site%2Findex');
$I->see('My Company');
$I->seeLink('About');
$I->click('About');
$I->see('This is the About page.');
}
}

View File

@ -1,37 +0,0 @@
<?php
use tests\codeception\_pages\LoginPage;
/* @var $scenario Codeception\Scenario */
$I = new AcceptanceTester($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('', '');
if (method_exists($I, 'wait')) {
$I->wait(3); // only for selenium
}
$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)');

View File

@ -0,0 +1,19 @@
<?php
class LoginCest
{
public function ensureThatLoginWorks(AcceptanceTester $I)
{
//$I->amOnPage(['site/login']);
$I->amOnPage('index.php?r=site%2Flogin');
$I->see('Login', 'h1');
$I->amGoingTo('try to login with correct credentials');
$I->fillField('input[name="LoginForm[username]"]', 'admin');
$I->fillField('input[name="LoginForm[password]"]', 'admin');
$I->click('login-button');
$I->expectTo('see user info');
$I->see('Logout (admin)');
}
}