Commit b82d32c1 by Alexander Makarov

Used a single database and a single CLI entry point for all test types. Added…

Used a single database and a single CLI entry point for all test types. Added faker to basic app dev requirements.
parent a7f998ed
......@@ -28,18 +28,10 @@ composer require --dev yiisoft/yii2-faker:*
```
3. Create three databases that are used in tests:
* `yii2_advanced_unit` - for unit tests;
* `yii2_advanced_functional` - for functional tests;
* `yii2_advanced_acceptance` - for acceptance tests.
Then update databases by applying migrations:
3. Create `yii2_advanced_tests` database then update it by applying migrations:
```
codeception/bin/yii_acceptance migrate
codeception/bin/yii_functional migrate
codeception/bin/yii_unit migrate
codeception/bin/yii migrate
```
4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in
......
......@@ -15,7 +15,7 @@ $config = yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
require(YII_APP_BASE_PATH . '/console/config/main.php'),
require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config/acceptance.php'),
require(dirname(__DIR__) . '/config/config.php'),
[
'controllerMap' => [
'fixture' => [
......
#!/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 . '/common/config/main.php'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
require(YII_APP_BASE_PATH . '/console/config/main.php'),
require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config/functional.php'),
[
'controllerMap' => [
'fixture' => [
'class' => 'yii\faker\FixtureController',
'fixtureDataPath' => dirname(__DIR__) . 'common/fixtures',
'templatePath' => dirname(__DIR__) . 'common/templates'
],
],
]
);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
@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
#!/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 . '/common/config/main.php'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
require(YII_APP_BASE_PATH . '/console/config/main.php'),
require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config/unit.php'),
[
'controllerMap' => [
'fixture' => [
'class' => 'yii\faker\FixtureController',
'fixtureDataPath' => dirname(__DIR__) . 'common/fixtures',
'templatePath' => dirname(__DIR__) . 'common/templates'
],
],
]
);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
@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
......@@ -3,9 +3,5 @@
* Application configuration shared by all applications acceptance tests
*/
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
];
\ No newline at end of file
......@@ -4,6 +4,9 @@
*/
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests',
],
'mailer' => [
'useFileTransport' => true,
],
......
......@@ -3,9 +3,5 @@
* Application configuration shared by all applications functional tests
*/
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
];
\ No newline at end of file
......@@ -3,9 +3,5 @@
* Application configuration shared by all applications unit tests
*/
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
];
\ No newline at end of file
......@@ -22,7 +22,8 @@
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*"
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"scripts": {
"post-create-project-cmd": [
......
......@@ -27,18 +27,10 @@ line globally.
composer require --dev yiisoft/yii2-faker:*
```
3. Create three databases that are used in tests:
* `yii2_basic_unit` - for unit tests;
* `yii2_basic_functional` - for functional tests;
* `yii2_basic_acceptance` - for acceptance tests.
Then update databases by applying migrations:
3. Create `yii2_basic_tests` database and update it by applying migrations:
```
codeception/bin/yii_acceptance migrate
codeception/bin/yii_functional migrate
codeception/bin/yii_unit migrate
codeception/bin/yii migrate
```
4. Build the test suites:
......
......@@ -21,11 +21,6 @@ $config = yii\helpers\ArrayHelper::merge(
'templatePath' => dirname(__DIR__) . 'templates'
],
],
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
],
],
]
);
......
#!/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);
@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
#!/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_unit',
],
],
]
);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
@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.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
],
],
]
);
......@@ -4,6 +4,9 @@
*/
return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests',
],
'mailer' => [
'useFileTransport' => true,
],
......
......@@ -9,10 +9,6 @@ return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../config/web.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.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
],
],
]
);
......@@ -4,12 +4,8 @@ if (php --version | grep -i HipHop > /dev/null); then
echo "skipping application init on HHVM"
else
mysql -e 'CREATE DATABASE yii2_advanced_acceptance;';
mysql -e 'CREATE DATABASE yii2_advanced_functional;';
mysql -e 'CREATE DATABASE yii2_advanced_unit;';
mysql -e 'CREATE DATABASE yii2_advanced_tests;';
cd apps/advanced/tests/codeception/bin
php yii_acceptance migrate --interactive=0
php yii_functional migrate --interactive=0
php yii_unit migrate --interactive=0
php yii migrate --interactive=0
cd ../../../../..
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment