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
<?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 |
|
*/ |
|
protected $baseConfig = '@tests/unit/_bootstrap.php'; |
|
|
|
/** |
|
* Your application config, will be merged with base config when creating application. Can be an alias too. |
|
* @var mixed |
|
*/ |
|
protected $config = array(); |
|
|
|
/** |
|
* Created application class |
|
* @var string |
|
*/ |
|
protected $appClass = '\yii\web\Application'; |
|
|
|
protected function setUp() |
|
{ |
|
parent::setUp(); |
|
$this->mockApplication(); |
|
} |
|
|
|
protected function tearDown() |
|
{ |
|
$this->destroyApplication(); |
|
parent::tearDown(); |
|
} |
|
|
|
protected function mockApplication() |
|
{ |
|
$baseConfig = is_array($this->baseConfig)? $this->baseConfig : require(Yii::getAlias($this->baseConfig, true)); |
|
$config = is_array($this->config)? $this->config : require(Yii::getAlias($this->config, true)); |
|
new $this->appClass(\yii\helpers\ArrayHelper::merge($baseConfig,$config)); |
|
} |
|
|
|
protected function destroyApplication() |
|
{ |
|
\Yii::$app = null; |
|
} |
|
|
|
}
|
|
|