Commit 6d64d62c by Qiang Xue

Fixed test break.

parent 4e4e76e8
......@@ -53,6 +53,22 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
new $appClass(ArrayHelper::merge($defaultConfig, $config));
}
protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
{
static $defaultConfig = [
'id' => 'testapp',
'basePath' => __DIR__,
'components' => [
'request' => [
'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
],
]
];
$defaultConfig['vendorPath'] = dirname(dirname(__DIR__)) . '/vendor';
new $appClass(ArrayHelper::merge($defaultConfig, $config));
}
/**
* Destroys application in Yii::$app by setting it to null.
*/
......
......@@ -27,7 +27,7 @@ class ActiveFieldTest extends \yiiunit\TestCase
$_SERVER['SCRIPT_FILENAME'] = "index.php";
$_SERVER['SCRIPT_NAME'] = "index.php";
$this->mockApplication([], 'yii\web\Application');
$this->mockWebApplication();
Yii::setAlias('@testWeb', '/');
Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
......
......@@ -20,7 +20,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase
$_SERVER['SCRIPT_FILENAME'] = "index.php";
$_SERVER['SCRIPT_NAME'] = "index.php";
$this->mockApplication([], 'yii\web\Application');
$this->mockWebApplication();
$this->breadcrumbs = new Breadcrumbs();
}
......
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