Acceptance tests refactoring (#1)
This commit is contained in:
parent
75a273eb40
commit
aaee0841e1
26
tests/codeception/_support/AcceptanceTester.php
Normal file
26
tests/codeception/_support/AcceptanceTester.php
Normal 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
|
||||||
|
*/
|
||||||
|
}
|
26
tests/codeception/_support/FunctionalTester.php
Normal file
26
tests/codeception/_support/FunctionalTester.php
Normal 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
|
||||||
|
*/
|
||||||
|
}
|
26
tests/codeception/_support/UnitTester.php
Normal file
26
tests/codeception/_support/UnitTester.php
Normal 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
|
||||||
|
*/
|
||||||
|
}
|
2
tests/codeception/_support/_generated/.gitignore
vendored
Normal file
2
tests/codeception/_support/_generated/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
@ -12,6 +12,8 @@ class_name: AcceptanceTester
|
|||||||
modules:
|
modules:
|
||||||
enabled:
|
enabled:
|
||||||
- PhpBrowser
|
- PhpBrowser
|
||||||
|
# - Yii2:
|
||||||
|
# configFile: '/codeception/config/acceptance.php'
|
||||||
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
|
# 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
|
# 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,
|
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
|
||||||
|
@ -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');
|
|
11
tests/codeception/acceptance/AboutCest.php
Normal file
11
tests/codeception/acceptance/AboutCest.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
@ -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.');
|
|
16
tests/codeception/acceptance/HomeCest.php
Normal file
16
tests/codeception/acceptance/HomeCest.php
Normal 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.');
|
||||||
|
}
|
||||||
|
}
|
@ -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)');
|
|
19
tests/codeception/acceptance/LoginCest.php
Normal file
19
tests/codeception/acceptance/LoginCest.php
Normal 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)');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user