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