Commit f21c2c29 by Qiang Xue

Fixed test breaks.

parent a27b6e92
......@@ -44,29 +44,36 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
*/
protected function mockApplication($config = [], $appClass = '\yii\console\Application')
{
static $defaultConfig = [
new $appClass(ArrayHelper::merge([
'id' => 'testapp',
'basePath' => __DIR__,
];
$defaultConfig['vendorPath'] = dirname(dirname(__DIR__)) . '/vendor';
new $appClass(ArrayHelper::merge($defaultConfig, $config));
'vendorPath' => $this->getVendorPath(),
], $config));
}
protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
{
static $defaultConfig = [
new $appClass(ArrayHelper::merge([
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => $this->getVendorPath(),
'components' => [
'request' => [
'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
'scriptFile' => __DIR__ .'/index.php',
'scriptUrl' => '/index.php',
],
]
];
$defaultConfig['vendorPath'] = dirname(dirname(__DIR__)) . '/vendor';
], $config));
}
new $appClass(ArrayHelper::merge($defaultConfig, $config));
protected function getVendorPath()
{
$vendor = dirname(dirname(__DIR__)) . '/vendor';
if (!is_dir($vendor)) {
$vendor = dirname(dirname(dirname(dirname(__DIR__))));
}
return $vendor;
}
/**
......
*
!.gitignore
!/coveralls/.gitkeep
......@@ -12,6 +12,8 @@ $_SERVER['SCRIPT_FILENAME'] = __FILE__;
$composerAutoload = __DIR__ . '/../../vendor/autoload.php';
if (is_file($composerAutoload)) {
require_once($composerAutoload);
} else {
require_once(__DIR__ . '/../../../../autoload.php');
}
require_once(__DIR__ . '/../../framework/Yii.php');
......
......@@ -22,7 +22,7 @@ class ViewRendererTest extends TestCase
protected function setUp()
{
parent::setUp();
$this->mockApplication();
$this->mockWebApplication();
}
protected function tearDown()
......
......@@ -22,7 +22,7 @@ class ViewRendererTest extends DatabaseTestCase
protected function setUp()
{
parent::setUp();
$this->mockApplication();
$this->mockWebApplication();
}
protected function tearDown()
......
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