Commit c30ee60e by Benjamin Wöster

add: new key for unit tests config named "className". Allows to run the tests

using different Application instances (consoleApp/ webApp) mod: TestCase::getParam accepts second param $default=null
parent 5e0f6604
......@@ -21,12 +21,12 @@ class TestCase extends \yii\test\TestCase
}
}
public function getParam($name)
public function getParam($name,$default=null)
{
if (self::$params === null) {
self::$params = require(__DIR__ . '/data/config.php');
}
return isset(self::$params[$name]) ? self::$params[$name] : null;
return isset(self::$params[$name]) ? self::$params[$name] : $default;
}
protected function requireApp($requiredConfig=array())
......@@ -38,12 +38,13 @@ class TestCase extends \yii\test\TestCase
);
$newConfig = array_merge( $defaultConfig, $requiredConfig );
$appClass = $this->getParam( 'appClass', '\yii\web\Application' );
if (!(\yii::$app instanceof \yii\web\Application)) {
new \yii\web\Application( $newConfig );
if (!(\yii::$app instanceof $appClass)) {
new $appClass( $newConfig );
$usedConfig = $newConfig;
} elseif ($newConfig !== $usedConfig) {
new \yii\web\Application( $newConfig );
new $appClass( $newConfig );
$usedConfig = $newConfig;
}
}
......
<?php
return array(
//'appClass' => '\yii\web\Application',
'appClass' => '\yii\console\Application',
'mysql' => array(
'dsn' => 'mysql:host=127.0.0.1;dbname=yiitest',
'username' => 'travis',
......
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