Commit f21c2c29 by Qiang Xue

Fixed test breaks.

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