浏览代码

Used a single database and a single CLI entry point for all test types. Added faker to basic app dev requirements.

Alexander Makarov 11 年之前
父节点
当前提交
459ac478a2

+ 2 - 1
composer.json

@@ -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": [

+ 2 - 10
tests/README.md

@@ -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:

+ 0 - 5
tests/codeception/bin/yii_unit

@@ -21,11 +21,6 @@ $config = yii\helpers\ArrayHelper::merge(
                 'templatePath' => dirname(__DIR__) . 'templates'
             ],
         ],
-        'components' => [
-            'db' => [
-                'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
-            ],
-        ],
     ]
 );
 

tests/codeception/bin/yii_acceptance.bat → tests/codeception/bin/yii.bat


+ 0 - 34
tests/codeception/bin/yii_acceptance

@@ -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);

+ 0 - 34
tests/codeception/bin/yii_functional

@@ -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);

+ 0 - 20
tests/codeception/bin/yii_functional.bat

@@ -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

+ 0 - 20
tests/codeception/bin/yii_unit.bat

@@ -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

+ 1 - 5
tests/codeception/config/acceptance.php

@@ -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',
-            ],
-        ],
+
     ]
 );

+ 3 - 0
tests/codeception/config/config.php

@@ -4,6 +4,9 @@
  */
 return [
     'components' => [
+        'db' => [
+            'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests',
+        ],
         'mailer' => [
             'useFileTransport' => true,
         ],

+ 1 - 5
tests/codeception/config/functional.php

@@ -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',
-            ],
-        ],
+
     ]
 );

+ 1 - 5
tests/codeception/config/unit.php

@@ -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',
-            ],
-        ],
+
     ]
 );