You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
11 years ago
|
<?php
|
||
|
|
||
|
namespace yii\codeception;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
class TestCase extends \PHPUnit_Framework_TestCase
|
||
|
{
|
||
|
/**
|
||
|
* Your application base config that will be used for creating application each time before test.
|
||
|
* This can be an array or alias, pointing to the config file. For example for console application it can be
|
||
|
* '@tests/unit/console_bootstrap.php' that can be similar to existing unit tests bootstrap file.
|
||
|
* @var mixed
|
||
|
*/
|
||
11 years ago
|
protected $baseConfig = '@app/config/web.php';
|
||
11 years ago
|
|
||
|
/**
|
||
|
* Your application config, will be merged with base config when creating application. Can be an alias too.
|
||
|
* @var mixed
|
||
|
*/
|
||
11 years ago
|
protected $config = [];
|
||
11 years ago
|
|
||
|
/**
|
||
|
* Created application class
|
||
|
* @var string
|
||
|
*/
|
||
11 years ago
|
protected $appClass = 'yii\web\Application';
|
||
11 years ago
|
|
||
|
protected function setUp()
|
||
|
{
|
||
|
parent::setUp();
|
||
|
$this->mockApplication();
|
||
|
}
|
||
|
|
||
|
protected function tearDown()
|
||
|
{
|
||
|
$this->destroyApplication();
|
||
|
parent::tearDown();
|
||
|
}
|
||
|
|
||
|
protected function mockApplication()
|
||
|
{
|
||
11 years ago
|
$baseConfig = is_array($this->baseConfig) ? $this->baseConfig : require(Yii::getAlias($this->baseConfig));
|
||
|
$config = is_array($this->config)? $this->config : require(Yii::getAlias($this->config));
|
||
11 years ago
|
new $this->appClass(\yii\helpers\ArrayHelper::merge($baseConfig,$config));
|
||
|
}
|
||
|
|
||
|
protected function destroyApplication()
|
||
|
{
|
||
|
\Yii::$app = null;
|
||
|
}
|
||
|
|
||
|
}
|