cleanup and re-aranged codeception tests for basic app
follow up to PR #1393
This commit is contained in:
parent
60bdb6b7cf
commit
09237c013e
@ -10,7 +10,7 @@ namespace app\commands;
|
|||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command echoes what the first argument that you have entered.
|
* This command echoes the first argument that you have entered.
|
||||||
*
|
*
|
||||||
* This command is provided as an example for you to learn how to create console commands.
|
* This command is provided as an example for you to learn how to create console commands.
|
||||||
*
|
*
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"yiisoft/yii2": "*",
|
"yiisoft/yii2": "*",
|
||||||
"yiisoft/yii2-swiftmailer": "*",
|
|
||||||
"yiisoft/yii2-bootstrap": "*",
|
"yiisoft/yii2-bootstrap": "*",
|
||||||
"yiisoft/yii2-codeception": "*",
|
"yiisoft/yii2-codeception": "*",
|
||||||
"yiisoft/yii2-debug": "*",
|
"yiisoft/yii2-debug": "*",
|
||||||
"yiisoft/yii2-gii": "*"
|
"yiisoft/yii2-gii": "*",
|
||||||
|
"yiisoft/yii2-swiftmailer": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// configuration adjustments for codeception acceptance tests. Will be merged with web.php config.
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// configuration adjustments for codeception functional tests. Will be merged with web.php config.
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'components' => [
|
'components' => [
|
||||||
'db' => [
|
'db' => [
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// configuration adjustments for codeception unit tests. Will be merged with web.php config.
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'components' => [
|
'components' => [
|
||||||
'fixture' => [
|
'fixture' => [
|
||||||
'class' => 'yii\test\DbFixtureManager',
|
'class' => 'yii\test\DbFixtureManager',
|
||||||
'basePath' => '@app/tests/unit/fixtures',
|
'basePath' => '@tests/unit/fixtures',
|
||||||
],
|
],
|
||||||
'db' => [
|
'db' => [
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2basic_unit',
|
'dsn' => 'mysql:host=localhost;dbname=yii2basic_unit',
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
Yii::setAlias('tests', realpath(__DIR__ . '/../tests'));
|
|
||||||
|
|
||||||
$config = require(__DIR__ . '/web.php');
|
|
||||||
|
|
||||||
// ... customize $config for the "test" environment here...
|
|
||||||
|
|
||||||
return $config;
|
|
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
Yii::setAlias('tests', realpath(__DIR__ . '/../tests'));
|
|
||||||
|
|
||||||
$params = require(__DIR__ . '/params.php');
|
$params = require(__DIR__ . '/params.php');
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
@ -41,10 +39,20 @@ $config = [
|
|||||||
'params' => $params,
|
'params' => $params,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (YII_ENV_DEV) {
|
if (YII_ENV_DEV)
|
||||||
|
{
|
||||||
|
// configuration adjustments for 'dev' environment
|
||||||
$config['preload'][] = 'debug';
|
$config['preload'][] = 'debug';
|
||||||
$config['modules']['debug'] = 'yii\debug\Module';
|
$config['modules']['debug'] = 'yii\debug\Module';
|
||||||
$config['modules']['gii'] = 'yii\gii\Module';
|
$config['modules']['gii'] = 'yii\gii\Module';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (YII_ENV_TEST)
|
||||||
|
{
|
||||||
|
// configuration adjustments for 'test' environment.
|
||||||
|
// configuration for codeception test environments can be found in codeception folder.
|
||||||
|
|
||||||
|
// if needed, customize $config here.
|
||||||
|
}
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
|
@ -3,17 +3,25 @@ These tests are developed with [Codeception PHP Testing Framework](http://codece
|
|||||||
|
|
||||||
To run the tests, follow these steps:
|
To run the tests, follow these steps:
|
||||||
|
|
||||||
1. [Install Codeception](http://codeception.com/quickstart) if you do not have it yet.
|
1. Download Codeception([Quickstart step 1](http://codeception.com/quickstart)) and put the codeception.phar in the
|
||||||
2. Create test configuration files based on your environment:
|
application base directory (not in this `tests` directory!).
|
||||||
- Copy `acceptance.suite.dist.yml` to `acceptance.suite.yml` and customize it;
|
2. Adjust the test configuration files based on your environment:
|
||||||
- Copy `functional.suite.dist.yml` to `functional.suite.yml` and customize it;
|
- Configure the URL for [acceptance tests](http://codeception.com/docs/04-AcceptanceTests) in `acceptance.suite.yml`.
|
||||||
- Copy `unit.suite.dist.yml` to `unit.suite.yml` and customize it.
|
The URL should point to the `index-test-acceptance.php` file that is located under the `web` directory of the application.
|
||||||
3. Switch to the parent folder and run tests:
|
- `functional.suite.yml` for [functional testing](http://codeception.com/docs/05-FunctionalTests) and
|
||||||
|
`unit.suite.yml` for [unit testing](http://codeception.com/docs/06-UnitTests) should already work out of the box
|
||||||
|
and should not need to be adjusted.
|
||||||
|
3. Go to the application base directory and build the test suites:
|
||||||
```
|
```
|
||||||
cd ..
|
|
||||||
php codecept.phar build // rebuild test scripts, only need to be run once
|
php codecept.phar build // rebuild test scripts, only need to be run once
|
||||||
|
```
|
||||||
|
4. Run the tests:
|
||||||
|
```
|
||||||
php codecept.phar run // run all available tests
|
php codecept.phar run // run all available tests
|
||||||
|
// you can also run a test suite alone:
|
||||||
|
php codecept.phar run acceptance
|
||||||
|
php codecept.phar run functional
|
||||||
|
php codecept.phar run unit
|
||||||
```
|
```
|
||||||
|
|
||||||
Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for
|
Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(__DIR__.'/yii_bootstrap.php');
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
|
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||||
|
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
||||||
|
|
||||||
|
Yii::setAlias('@tests', __DIR__);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Codeception\Module;
|
namespace Codeception\Module;
|
||||||
|
|
||||||
// here you can define custom functions for CodeGuy
|
|
||||||
|
|
||||||
class CodeHelper extends \Codeception\Module
|
class CodeHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
|
// here you can define custom methods for CodeGuy
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Codeception\Module;
|
namespace Codeception\Module;
|
||||||
|
|
||||||
// here you can define custom functions for TestGuy
|
|
||||||
|
|
||||||
class TestHelper extends \Codeception\Module
|
class TestHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
|
// here you can define custom methods for TestGuy
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Codeception\Module;
|
namespace Codeception\Module;
|
||||||
|
|
||||||
// here you can define custom functions for WebGuy
|
|
||||||
|
|
||||||
class WebHelper extends \Codeception\Module
|
class WebHelper extends \Codeception\Module
|
||||||
{
|
{
|
||||||
|
// here you can define custom methods for WebGuy
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace tests\_pages;
|
namespace tests\_pages;
|
||||||
|
|
||||||
class AboutPage extends \yii\codeception\BasePage
|
use yii\codeception\BasePage;
|
||||||
|
|
||||||
|
class AboutPage extends BasePage
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $URL = '?r=site/about';
|
public static $URL = '?r=site/about';
|
||||||
|
|
||||||
}
|
}
|
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace tests\_pages;
|
namespace tests\_pages;
|
||||||
|
|
||||||
class ContactPage extends \yii\codeception\BasePage
|
use yii\codeception\BasePage;
|
||||||
{
|
|
||||||
|
|
||||||
|
class ContactPage extends BasePage
|
||||||
|
{
|
||||||
public static $URL = '?r=site/contact';
|
public static $URL = '?r=site/contact';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,31 +13,26 @@ class ContactPage extends \yii\codeception\BasePage
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $name = 'input[name="ContactForm[name]"]';
|
public $name = 'input[name="ContactForm[name]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form email text field locator
|
* contact form email text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $email = 'input[name="ContactForm[email]"]';
|
public $email = 'input[name="ContactForm[email]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form subject text field locator
|
* contact form subject text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $subject = 'input[name="ContactForm[subject]"]';
|
public $subject = 'input[name="ContactForm[subject]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form body textarea locator
|
* contact form body textarea locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $body = 'textarea[name="ContactForm[body]"]';
|
public $body = 'textarea[name="ContactForm[body]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form verification code text field locator
|
* contact form verification code text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $verifyCode = 'input[name="ContactForm[verifyCode]"]';
|
public $verifyCode = 'input[name="ContactForm[verifyCode]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form submit button
|
* contact form submit button
|
||||||
* @var string
|
* @var string
|
||||||
@ -59,5 +55,4 @@ class ContactPage extends \yii\codeception\BasePage
|
|||||||
}
|
}
|
||||||
$this->guy->click($this->button);
|
$this->guy->click($this->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace tests\_pages;
|
namespace tests\_pages;
|
||||||
|
|
||||||
class LoginPage extends \yii\codeception\BasePage
|
use yii\codeception\BasePage;
|
||||||
{
|
|
||||||
|
|
||||||
|
class LoginPage extends BasePage
|
||||||
|
{
|
||||||
public static $URL = '?r=site/login';
|
public static $URL = '?r=site/login';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,13 +13,11 @@ class LoginPage extends \yii\codeception\BasePage
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $username = 'input[name="LoginForm[username]"]';
|
public $username = 'input[name="LoginForm[username]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* login form password text field locator
|
* login form password text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $password = 'input[name="LoginForm[password]"]';
|
public $password = 'input[name="LoginForm[password]"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* login form submit button locator
|
* login form submit button locator
|
||||||
* @var string
|
* @var string
|
||||||
@ -36,5 +35,4 @@ class LoginPage extends \yii\codeception\BasePage
|
|||||||
$this->guy->fillField($this->password, $password);
|
$this->guy->fillField($this->password, $password);
|
||||||
$this->guy->click($this->button);
|
$this->guy->click($this->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
# Codeception Test Suite Configuration
|
|
||||||
|
|
||||||
# suite for acceptance tests.
|
|
||||||
# perform tests in browser using the Selenium-like tools.
|
|
||||||
# powered by Mink (http://mink.behat.org).
|
|
||||||
# (tip: that's what your customer will see).
|
|
||||||
# (tip: test your ajax and javascript by one of Mink drivers).
|
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
|
||||||
|
|
||||||
class_name: WebGuy
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
- WebHelper
|
|
||||||
- WebDriver
|
|
||||||
config:
|
|
||||||
WebDriver:
|
|
||||||
url: 'http://localhost/basic/web/index-test-accept.php'
|
|
||||||
browser: firefox
|
|
24
tests/acceptance.suite.yml
Normal file
24
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Codeception Test Suite Configuration
|
||||||
|
|
||||||
|
# suite for acceptance tests.
|
||||||
|
# perform tests in browser using the Selenium-like tools.
|
||||||
|
# powered by Mink (http://mink.behat.org).
|
||||||
|
# (tip: that's what your customer will see).
|
||||||
|
# (tip: test your ajax and javascript by one of Mink drivers).
|
||||||
|
|
||||||
|
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
||||||
|
|
||||||
|
class_name: WebGuy
|
||||||
|
modules:
|
||||||
|
enabled:
|
||||||
|
- WebHelper
|
||||||
|
- PhpBrowser
|
||||||
|
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
|
||||||
|
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
|
||||||
|
# - WebDriver
|
||||||
|
config:
|
||||||
|
PhpBrowser:
|
||||||
|
url: 'http://localhost/basic-app/web/index-test-acceptance.php'
|
||||||
|
# WebDriver:
|
||||||
|
# url: 'http://localhost/basic-app/web/index-test-acceptance.php'
|
||||||
|
# browser: firefox
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use tests\_pages\AboutPage;
|
use tests\_pages\AboutPage;
|
||||||
|
|
||||||
$I = new WebGuy($scenario);
|
$I = new WebGuy($scenario);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use tests\_pages\ContactPage;
|
use tests\_pages\ContactPage;
|
||||||
|
|
||||||
$I = new WebGuy($scenario);
|
$I = new WebGuy($scenario);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$I = new WebGuy($scenario);
|
$I = new WebGuy($scenario);
|
||||||
$I->wantTo('ensure that home page works');
|
$I->wantTo('ensure that home page works');
|
||||||
$I->amOnPage('');
|
$I->amOnPage('');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use tests\_pages\LoginPage;
|
use tests\_pages\LoginPage;
|
||||||
|
|
||||||
$I = new WebGuy($scenario);
|
$I = new WebGuy($scenario);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// Here you can initialize variables that will for your tests
|
|
||||||
|
|
||||||
$config = require(__DIR__.'/../yii_bootstrap.php');
|
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
$config = yii\helpers\ArrayHelper::merge(
|
||||||
$config,
|
require(__DIR__ . '/../../config/web.php'),
|
||||||
require(__DIR__ . '/../../config/codeception/acceptance.php')
|
require(__DIR__ . '/../../config/codeception/acceptance.php')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5,11 +5,14 @@
|
|||||||
# (tip: better to use with frameworks).
|
# (tip: better to use with frameworks).
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
||||||
#basic/web/index-test-func.php
|
#basic/web/index.php
|
||||||
class_name: TestGuy
|
class_name: TestGuy
|
||||||
modules:
|
modules:
|
||||||
enabled: [Filesystem, TestHelper, Yii2]
|
enabled:
|
||||||
|
- Filesystem
|
||||||
|
- TestHelper
|
||||||
|
- Yii2
|
||||||
config:
|
config:
|
||||||
Yii2:
|
Yii2:
|
||||||
entryScript: 'web/index-test-func.php'
|
entryScript: 'web/index-test-functional.php'
|
||||||
url: 'http://localhost/'
|
url: 'http://localhost/'
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use tests\functional\_pages\ContactPage;
|
use tests\functional\_pages\ContactPage;
|
||||||
|
|
||||||
$I = new TestGuy($scenario);
|
$I = new TestGuy($scenario);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$I = new TestGuy($scenario);
|
$I = new TestGuy($scenario);
|
||||||
$I->wantTo('ensure that home page works');
|
$I->wantTo('ensure that home page works');
|
||||||
$I->amOnPage('');
|
$I->amOnPage('');
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use tests\functional\_pages\LoginPage;
|
use tests\functional\_pages\LoginPage;
|
||||||
|
|
||||||
$I = new TestGuy($scenario);
|
$I = new TestGuy($scenario);
|
||||||
|
@ -1698,8 +1698,8 @@ class TestGuy extends \Codeception\AbstractGuy
|
|||||||
*
|
*
|
||||||
* ``` php
|
* ``` php
|
||||||
* <?php
|
* <?php
|
||||||
* $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true); // POST
|
* $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST
|
||||||
* $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true); // GET
|
* $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
@ -1718,6 +1718,40 @@ class TestGuy extends \Codeception\AbstractGuy
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is generated.
|
||||||
|
* Documentation taken from corresponding module.
|
||||||
|
* ----------------------------------------------
|
||||||
|
*
|
||||||
|
* If your page triggers an ajax request, you can perform it manually.
|
||||||
|
* This action sends an ajax request with specified method and params.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* You need to perform an ajax request specifying the HTTP method.
|
||||||
|
*
|
||||||
|
* ``` php
|
||||||
|
* <?php
|
||||||
|
* $I->sendAjaxRequest('PUT', /posts/7', array('title' => 'new title');
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param $method
|
||||||
|
* @param $uri
|
||||||
|
* @param $params
|
||||||
|
* @see Codeception\Util\Framework::sendAjaxRequest()
|
||||||
|
* @return \Codeception\Maybe
|
||||||
|
*/
|
||||||
|
public function sendAjaxRequest($method, $uri, $params = null) {
|
||||||
|
$this->scenario->addStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args()));
|
||||||
|
if ($this->scenario->running()) {
|
||||||
|
$result = $this->scenario->runStep();
|
||||||
|
return new Maybe($result);
|
||||||
|
}
|
||||||
|
return new Maybe();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is generated.
|
* This method is generated.
|
||||||
* Documentation taken from corresponding module.
|
* Documentation taken from corresponding module.
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = require(__DIR__.'/../yii_bootstrap.php');
|
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
$config = yii\helpers\ArrayHelper::merge(
|
||||||
$config,
|
require(__DIR__ . '/../../config/web.php'),
|
||||||
require(__DIR__ . '/../../config/codeception/functional.php')
|
require(__DIR__ . '/../../config/codeception/functional.php')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,31 +4,26 @@ namespace tests\functional\_pages;
|
|||||||
|
|
||||||
class ContactPage extends \tests\_pages\ContactPage
|
class ContactPage extends \tests\_pages\ContactPage
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form name text field locator
|
* contact form name text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $name = 'ContactForm[name]';
|
public $name = 'ContactForm[name]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form email text field locator
|
* contact form email text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $email = 'ContactForm[email]';
|
public $email = 'ContactForm[email]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form subject text field locator
|
* contact form subject text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $subject = 'ContactForm[subject]';
|
public $subject = 'ContactForm[subject]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form body textarea locator
|
* contact form body textarea locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $body = 'ContactForm[body]';
|
public $body = 'ContactForm[body]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* contact form verification code text field locator
|
* contact form verification code text field locator
|
||||||
* @var string
|
* @var string
|
||||||
@ -41,9 +36,9 @@ class ContactPage extends \tests\_pages\ContactPage
|
|||||||
*/
|
*/
|
||||||
public function submit(array $contactData)
|
public function submit(array $contactData)
|
||||||
{
|
{
|
||||||
if (empty($contactData))
|
if (empty($contactData)) {
|
||||||
$this->guy->submitForm('#contact-form', []);
|
$this->guy->submitForm('#contact-form', []);
|
||||||
else
|
} else {
|
||||||
$this->guy->submitForm('#contact-form', [
|
$this->guy->submitForm('#contact-form', [
|
||||||
$this->name => $contactData['name'],
|
$this->name => $contactData['name'],
|
||||||
$this->email => $contactData['email'],
|
$this->email => $contactData['email'],
|
||||||
@ -52,5 +47,5 @@ class ContactPage extends \tests\_pages\ContactPage
|
|||||||
$this->verifyCode => $contactData['verifyCode'],
|
$this->verifyCode => $contactData['verifyCode'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,11 @@ namespace tests\functional\_pages;
|
|||||||
|
|
||||||
class LoginPage extends \tests\_pages\LoginPage
|
class LoginPage extends \tests\_pages\LoginPage
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* login form username text field locator
|
* login form username text field locator
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $username = 'LoginForm[username]';
|
public $username = 'LoginForm[username]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* login form password text field locator
|
* login form password text field locator
|
||||||
* @var string
|
* @var string
|
||||||
@ -29,5 +27,4 @@ class LoginPage extends \tests\_pages\LoginPage
|
|||||||
$this->password => $password,
|
$this->password => $password,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = require(__DIR__.'/../yii_bootstrap.php');
|
// add unit testing specific bootstrap code here
|
||||||
|
|
||||||
return yii\helpers\ArrayHelper::merge(
|
|
||||||
$config,
|
|
||||||
require(__DIR__ . '/../../config/codeception/unit.php')
|
|
||||||
);
|
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace tests\unit\models;
|
namespace tests\unit\models;
|
||||||
|
|
||||||
class ContactFormTest extends \yii\codeception\TestCase
|
use yii\codeception\TestCase;
|
||||||
{
|
|
||||||
|
|
||||||
|
class ContactFormTest extends TestCase
|
||||||
|
{
|
||||||
|
// TODO add test methods here
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace tests\unit\models;
|
namespace tests\unit\models;
|
||||||
|
|
||||||
class LoginFormTest extends \yii\codeception\TestCase
|
use yii\codeception\TestCase;
|
||||||
{
|
|
||||||
|
|
||||||
|
class LoginFormTest extends TestCase
|
||||||
|
{
|
||||||
|
// TODO add test methods here
|
||||||
}
|
}
|
@ -2,24 +2,19 @@
|
|||||||
|
|
||||||
namespace tests\unit\models;
|
namespace tests\unit\models;
|
||||||
|
|
||||||
#use yii\test\DbTestTrait;
|
use yii\codeception\TestCase;
|
||||||
|
use yii\test\DbTestTrait;
|
||||||
|
|
||||||
class UserTest extends \yii\codeception\TestCase
|
class UserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
use DbTestTrait;
|
use DbTestTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
*
|
|
||||||
* you can load fixtures in this way
|
|
||||||
*
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->loadFixtures([
|
// uncomment the following to load fixtures for table tbl_user
|
||||||
'tbl_user',
|
//$this->loadFixtures(['tbl_user']);
|
||||||
]);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add test methods here
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
|
||||||
|
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
|
||||||
|
|
||||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
|
||||||
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
|
||||||
|
|
||||||
return require(__DIR__ . '/../config/web.php');
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// comment out the following two lines when deployed to production
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
|
||||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
|
||||||
|
|
||||||
require(__DIR__ . '/../vendor/autoload.php');
|
|
||||||
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
|
||||||
|
|
||||||
$config = require(__DIR__ . '/../config/web.php');
|
|
||||||
|
|
||||||
$application = new yii\web\Application($config);
|
|
||||||
$application->run();
|
|
@ -1,14 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
// NOTE: Make sure this file is not accessable when deployed to production
|
||||||
|
|
||||||
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||||
|
|
||||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
require(__DIR__ . '/../vendor/autoload.php');
|
||||||
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
$config = yii\helpers\ArrayHelper::merge(
|
||||||
require(__DIR__ . '/../config/web-test.php'),
|
require(__DIR__ . '/../config/web.php'),
|
||||||
require(__DIR__ . '/../config/codeception/acceptance.php')
|
require(__DIR__ . '/../config/codeception/acceptance.php')
|
||||||
);
|
);
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
|
||||||
|
|
||||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
|
||||||
|
|
||||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
|
||||||
require_once(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
|
||||||
require(__DIR__ . '/../config/web-test.php'),
|
|
||||||
require(__DIR__ . '/../config/codeception/functional.php')
|
|
||||||
);
|
|
||||||
|
|
||||||
$config['class'] = 'yii\web\Application';
|
|
||||||
return $config;
|
|
11
web/index-test-functional.php
Normal file
11
web/index-test-functional.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// this file is used as the entry script for codeception functional testing
|
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge(
|
||||||
|
require(__DIR__ . '/../config/web.php'),
|
||||||
|
require(__DIR__ . '/../config/codeception/functional.php')
|
||||||
|
);
|
||||||
|
|
||||||
|
$config['class'] = 'yii\web\Application';
|
||||||
|
return $config;
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// comment out the following two lines when deployed to production
|
// comment out the following two lines when deployed to production
|
||||||
defined('YII_DEBUG') or define('YII_DEBUG', false);
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
defined('YII_ENV') or define('YII_ENV', 'prod');
|
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||||
|
|
||||||
require(__DIR__ . '/../vendor/autoload.php');
|
require(__DIR__ . '/../vendor/autoload.php');
|
||||||
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
require(__DIR__ . '/../vendor/yiisoft/yii2/yii/Yii.php');
|
||||||
|
Loading…
Reference in New Issue
Block a user