mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-18 17:21:26 +08:00
Fixed test break.
This commit is contained in:
@ -53,6 +53,22 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
|
|||||||
new $appClass(ArrayHelper::merge($defaultConfig, $config));
|
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.
|
* 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_FILENAME'] = "index.php";
|
||||||
$_SERVER['SCRIPT_NAME'] = "index.php";
|
$_SERVER['SCRIPT_NAME'] = "index.php";
|
||||||
|
|
||||||
$this->mockApplication([], 'yii\web\Application');
|
$this->mockWebApplication();
|
||||||
|
|
||||||
Yii::setAlias('@testWeb', '/');
|
Yii::setAlias('@testWeb', '/');
|
||||||
Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
|
Yii::setAlias('@testWebRoot', '@yiiunit/data/web');
|
||||||
|
@ -20,7 +20,7 @@ class BreadcrumbsTest extends \yiiunit\TestCase
|
|||||||
$_SERVER['SCRIPT_FILENAME'] = "index.php";
|
$_SERVER['SCRIPT_FILENAME'] = "index.php";
|
||||||
$_SERVER['SCRIPT_NAME'] = "index.php";
|
$_SERVER['SCRIPT_NAME'] = "index.php";
|
||||||
|
|
||||||
$this->mockApplication([], 'yii\web\Application');
|
$this->mockWebApplication();
|
||||||
$this->breadcrumbs = new Breadcrumbs();
|
$this->breadcrumbs = new Breadcrumbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user