Qiang Xue 12 年 前
コミット
905e8ea4bc
6 ファイル変更58 行追加48 行削除
  1. 0 7
      config/web.php
  2. 1 1
      tests/_bootstrap.php
  3. 11 0
      tests/_config.php
  4. 16 13
      tests/acceptance/_config.php
  5. 16 13
      tests/functional/_config.php
  6. 14 14
      tests/unit/_config.php

+ 0 - 7
config/web.php

@@ -47,11 +47,4 @@ if (YII_ENV_DEV) {
 	$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;

+ 1 - 1
tests/_bootstrap.php

@@ -2,7 +2,7 @@
 
 // the entry script URL (without host info) for functional and acceptance tests
 // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
-defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/yii2-basic/web/index-test.php');
+defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/basic/web/index-test.php');
 
 // the entry script file path for functional and acceptance tests
 defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');

+ 11 - 0
tests/_config.php

@@ -0,0 +1,11 @@
+<?php
+/**
+ * application configurations shared by all test types
+ */
+return [
+	'components' => [
+		'mail' => [
+			'useFileTransport' => true,
+		],
+	],
+];

+ 16 - 13
tests/acceptance/_config.php

@@ -1,16 +1,19 @@
 <?php
 
-use yii\helpers\ArrayHelper;
-
-$config = require(__DIR__ . '/../../config/web.php');
-
-return ArrayHelper::merge($config, [
-	'components' => [
-		'db' => [
-			'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
-		],
-		'urlManager' => [
-			'showScriptName' => true,
+return yii\helpers\ArrayHelper::merge(
+	require(__DIR__ . '/../../config/web.php'),
+	require(__DIR__ . '/../_config.php'),
+	[
+		'components' => [
+			'db' => [
+				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
+			],
+			'mail' => [
+				'useFileTransport' => true,
+			],
+			'urlManager' => [
+				'showScriptName' => true,
+			],
 		],
-	],
-]);
+	]
+);

+ 16 - 13
tests/functional/_config.php

@@ -1,20 +1,23 @@
 <?php
 
-use yii\helpers\ArrayHelper;
-
 // set correct script paths
 $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
 $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
 
-$config = require(__DIR__ . '/../../config/web.php');
-
-return ArrayHelper::merge($config, [
-	'components' => [
-		'db' => [
-			'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
-		],
-		'urlManager' => [
-			'showScriptName' => true,
+return yii\helpers\ArrayHelper::merge(
+	require(__DIR__ . '/../../config/web.php'),
+	require(__DIR__ . '/../_config.php'),
+	[
+		'components' => [
+			'db' => [
+				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
+			],
+			'mail' => [
+				'useFileTransport' => true,
+			],
+			'urlManager' => [
+				'showScriptName' => true,
+			],
 		],
-	],
-]);
+	]
+);

+ 14 - 14
tests/unit/_config.php

@@ -1,17 +1,17 @@
 <?php
 
-use yii\helpers\ArrayHelper;
-
-$config = require(__DIR__ . '/../../config/web.php');
-
-return ArrayHelper::merge($config, [
-	'components' => [
-		'fixture' => [
-			'class' => 'yii\test\DbFixtureManager',
-			'basePath' => '@tests/unit/fixtures',
-		],
-		'db' => [
-			'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+return yii\helpers\ArrayHelper::merge(
+	require(__DIR__ . '/../../config/web.php'),
+	require(__DIR__ . '/../_config.php'),
+	[
+		'components' => [
+			'fixture' => [
+				'class' => 'yii\test\DbFixtureManager',
+				'basePath' => '@tests/unit/fixtures',
+			],
+			'db' => [
+				'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+			],
 		],
-	],
-]);
+	]
+);