Used a single database and a single CLI entry point for all test types. Added faker to basic app dev requirements.
This commit is contained in:
parent
2e9a0839dd
commit
459ac478a2
@ -22,7 +22,8 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-codeception": "*",
|
"yiisoft/yii2-codeception": "*",
|
||||||
"yiisoft/yii2-debug": "*",
|
"yiisoft/yii2-debug": "*",
|
||||||
"yiisoft/yii2-gii": "*"
|
"yiisoft/yii2-gii": "*",
|
||||||
|
"yiisoft/yii2-faker": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-create-project-cmd": [
|
"post-create-project-cmd": [
|
||||||
|
@ -27,18 +27,10 @@ line globally.
|
|||||||
composer require --dev yiisoft/yii2-faker:*
|
composer require --dev yiisoft/yii2-faker:*
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Create three databases that are used in tests:
|
3. Create `yii2_basic_tests` database and update it by applying migrations:
|
||||||
|
|
||||||
* `yii2_basic_unit` - for unit tests;
|
|
||||||
* `yii2_basic_functional` - for functional tests;
|
|
||||||
* `yii2_basic_acceptance` - for acceptance tests.
|
|
||||||
|
|
||||||
Then update databases by applying migrations:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
codeception/bin/yii_acceptance migrate
|
codeception/bin/yii migrate
|
||||||
codeception/bin/yii_functional migrate
|
|
||||||
codeception/bin/yii_unit migrate
|
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Build the test suites:
|
4. Build the test suites:
|
||||||
|
@ -21,11 +21,6 @@ $config = yii\helpers\ArrayHelper::merge(
|
|||||||
'templatePath' => dirname(__DIR__) . 'templates'
|
'templatePath' => dirname(__DIR__) . 'templates'
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Yii console bootstrap file.
|
|
||||||
*
|
|
||||||
* @link http://www.yiiframework.com/
|
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
||||||
* @license http://www.yiiframework.com/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once __DIR__ . '/_bootstrap.php';
|
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
|
||||||
require(YII_APP_BASE_PATH . '/config/console.php'),
|
|
||||||
require(__DIR__ . '/../config/config.php'),
|
|
||||||
[
|
|
||||||
'controllerMap' => [
|
|
||||||
'fixture' => [
|
|
||||||
'class' => 'yii\faker\FixtureController',
|
|
||||||
'fixtureDataPath' => dirname(__DIR__) . 'fixtures',
|
|
||||||
'templatePath' => dirname(__DIR__) . 'templates'
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$application = new yii\console\Application($config);
|
|
||||||
$exitCode = $application->run();
|
|
||||||
exit($exitCode);
|
|
@ -1,34 +0,0 @@
|
|||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Yii console bootstrap file.
|
|
||||||
*
|
|
||||||
* @link http://www.yiiframework.com/
|
|
||||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
||||||
* @license http://www.yiiframework.com/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once __DIR__ . '/_bootstrap.php';
|
|
||||||
|
|
||||||
$config = yii\helpers\ArrayHelper::merge(
|
|
||||||
require(YII_APP_BASE_PATH . '/config/console.php'),
|
|
||||||
require(__DIR__ . '/../config/config.php'),
|
|
||||||
[
|
|
||||||
'controllerMap' => [
|
|
||||||
'fixture' => [
|
|
||||||
'class' => 'yii\faker\FixtureController',
|
|
||||||
'fixtureDataPath' => dirname(__DIR__) . 'fixtures',
|
|
||||||
'templatePath' => dirname(__DIR__) . 'templates'
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$application = new yii\console\Application($config);
|
|
||||||
$exitCode = $application->run();
|
|
||||||
exit($exitCode);
|
|
@ -1,20 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
rem -------------------------------------------------------------
|
|
||||||
rem Yii command line bootstrap script for Windows.
|
|
||||||
rem
|
|
||||||
rem @author Qiang Xue <qiang.xue@gmail.com>
|
|
||||||
rem @link http://www.yiiframework.com/
|
|
||||||
rem @copyright Copyright (c) 2008 Yii Software LLC
|
|
||||||
rem @license http://www.yiiframework.com/license/
|
|
||||||
rem -------------------------------------------------------------
|
|
||||||
|
|
||||||
@setlocal
|
|
||||||
|
|
||||||
set YII_PATH=%~dp0
|
|
||||||
|
|
||||||
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
|
|
||||||
|
|
||||||
"%PHP_COMMAND%" "%YII_PATH%yii_functional" %*
|
|
||||||
|
|
||||||
@endlocal
|
|
@ -1,20 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
rem -------------------------------------------------------------
|
|
||||||
rem Yii command line bootstrap script for Windows.
|
|
||||||
rem
|
|
||||||
rem @author Qiang Xue <qiang.xue@gmail.com>
|
|
||||||
rem @link http://www.yiiframework.com/
|
|
||||||
rem @copyright Copyright (c) 2008 Yii Software LLC
|
|
||||||
rem @license http://www.yiiframework.com/license/
|
|
||||||
rem -------------------------------------------------------------
|
|
||||||
|
|
||||||
@setlocal
|
|
||||||
|
|
||||||
set YII_PATH=%~dp0
|
|
||||||
|
|
||||||
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
|
|
||||||
|
|
||||||
"%PHP_COMMAND%" "%YII_PATH%yii_unit" %*
|
|
||||||
|
|
||||||
@endlocal
|
|
@ -6,10 +6,6 @@ return yii\helpers\ArrayHelper::merge(
|
|||||||
require(__DIR__ . '/../../../config/web.php'),
|
require(__DIR__ . '/../../../config/web.php'),
|
||||||
require(__DIR__ . '/config.php'),
|
require(__DIR__ . '/config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'components' => [
|
'components' => [
|
||||||
|
'db' => [
|
||||||
|
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests',
|
||||||
|
],
|
||||||
'mailer' => [
|
'mailer' => [
|
||||||
'useFileTransport' => true,
|
'useFileTransport' => true,
|
||||||
],
|
],
|
||||||
|
@ -9,10 +9,6 @@ return yii\helpers\ArrayHelper::merge(
|
|||||||
require(__DIR__ . '/../../../config/web.php'),
|
require(__DIR__ . '/../../../config/web.php'),
|
||||||
require(__DIR__ . '/config.php'),
|
require(__DIR__ . '/config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -6,10 +6,6 @@ return yii\helpers\ArrayHelper::merge(
|
|||||||
require(__DIR__ . '/../../../config/web.php'),
|
require(__DIR__ . '/../../../config/web.php'),
|
||||||
require(__DIR__ . '/config.php'),
|
require(__DIR__ . '/config.php'),
|
||||||
[
|
[
|
||||||
'components' => [
|
|
||||||
'db' => [
|
|
||||||
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user