Merge branch 'master' of github.com:notgosu/yii2-app-basic
This commit is contained in:
commit
4a7f3dfb55
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\_pages;
|
||||
|
||||
use yii\codeception\BasePage;
|
||||
|
||||
/**
|
||||
* Represents contact page
|
||||
* @property \AcceptanceTester|\FunctionalTester $actor
|
||||
*/
|
||||
class ContactPage extends BasePage
|
||||
{
|
||||
public $route = 'site/contact';
|
||||
|
||||
/**
|
||||
* @param array $contactData
|
||||
*/
|
||||
public function submit(array $contactData)
|
||||
{
|
||||
foreach ($contactData as $field => $value) {
|
||||
$inputType = $field === 'body' ? 'textarea' : 'input';
|
||||
$this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
|
||||
}
|
||||
$this->actor->click('contact-button');
|
||||
}
|
||||
}
|
2
tests/codeception/_support/.gitignore
vendored
Normal file
2
tests/codeception/_support/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
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:
|
||||
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,
|
||||
|
@ -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,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\ContactPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new AcceptanceTester($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([]);
|
||||
if (method_exists($I, 'wait')) {
|
||||
$I->wait(3); // only for selenium
|
||||
}
|
||||
$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',
|
||||
]);
|
||||
if (method_exists($I, 'wait')) {
|
||||
$I->wait(3); // only for selenium
|
||||
}
|
||||
$I->expectTo('see that email address 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.');
|
33
tests/codeception/acceptance/ContactCest.php
Normal file
33
tests/codeception/acceptance/ContactCest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ContactCest
|
||||
*/
|
||||
class ContactCest
|
||||
{
|
||||
public function _before(\AcceptanceTester $I)
|
||||
{
|
||||
$I->amOnPage('index-test.php?r=site%2Fcontact');
|
||||
}
|
||||
|
||||
public function contactPageWorks(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('ensure that contact page works');
|
||||
$I->see('Contact', 'h1');
|
||||
}
|
||||
|
||||
public function contactFormCanBeSubmitted(AcceptanceTester $I)
|
||||
{
|
||||
$I->amGoingTo('submit contact form with correct data');
|
||||
$I->fillField('#contactform-name', 'tester');
|
||||
$I->fillField('#contactform-email', 'tester@example.com');
|
||||
$I->fillField('#contactform-subject', 'test subject');
|
||||
$I->fillField('#contactform-body', 'test content');
|
||||
$I->fillField('#contactform-verifycode', 'testme');
|
||||
|
||||
$I->click('contact-button');
|
||||
|
||||
$I->dontSeeElement('#contact-form');
|
||||
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
|
||||
}
|
||||
}
|
@ -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