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:* ...@@ -28,18 +28,10 @@ composer require --dev yiisoft/yii2-faker:*
``` ```
3. Create three databases that are used in tests: 3. Create `yii2_advanced_tests` database then update it by applying migrations:
* `yii2_advanced_unit` - for unit tests;
* `yii2_advanced_functional` - for functional tests;
* `yii2_advanced_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. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in 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( ...@@ -15,7 +15,7 @@ $config = yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main-local.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.php'),
require(YII_APP_BASE_PATH . '/console/config/main-local.php'), require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config/acceptance.php'), require(dirname(__DIR__) . '/config/config.php'),
[ [
'controllerMap' => [ 'controllerMap' => [
'fixture' => [ '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 @@ ...@@ -3,9 +3,5 @@
* Application configuration shared by all applications acceptance tests * Application configuration shared by all applications acceptance tests
*/ */
return [ return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
]; ];
\ No newline at end of file
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
*/ */
return [ return [
'components' => [ 'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests',
],
'mailer' => [ 'mailer' => [
'useFileTransport' => true, 'useFileTransport' => true,
], ],
......
...@@ -3,9 +3,5 @@ ...@@ -3,9 +3,5 @@
* Application configuration shared by all applications functional tests * Application configuration shared by all applications functional tests
*/ */
return [ return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
]; ];
\ No newline at end of file
...@@ -3,9 +3,5 @@ ...@@ -3,9 +3,5 @@
* Application configuration shared by all applications unit tests * Application configuration shared by all applications unit tests
*/ */
return [ return [
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
]; ];
\ No newline at end of file
...@@ -22,7 +22,8 @@ ...@@ -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. ...@@ -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( ...@@ -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_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( ...@@ -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 @@ ...@@ -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( ...@@ -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( ...@@ -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',
],
],
] ]
); );
...@@ -4,12 +4,8 @@ if (php --version | grep -i HipHop > /dev/null); then ...@@ -4,12 +4,8 @@ if (php --version | grep -i HipHop > /dev/null); then
echo "skipping application init on HHVM" echo "skipping application init on HHVM"
else else
mysql -e 'CREATE DATABASE yii2_advanced_acceptance;'; mysql -e 'CREATE DATABASE yii2_advanced_tests;';
mysql -e 'CREATE DATABASE yii2_advanced_functional;';
mysql -e 'CREATE DATABASE yii2_advanced_unit;';
cd apps/advanced/tests/codeception/bin cd apps/advanced/tests/codeception/bin
php yii_acceptance migrate --interactive=0 php yii migrate --interactive=0
php yii_functional migrate --interactive=0
php yii_unit migrate --interactive=0
cd ../../../../.. cd ../../../../..
fi 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