123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * @link http://www.yiiframework.com/
- * @copyright Copyright (c) 2008 Yii Software LLC
- * @license http://www.yiiframework.com/license/
- */
- namespace yiiunit\twig;
- use yii\di\Container;
- use yii\helpers\ArrayHelper;
- use Yii;
- /**
- * This is the base class for all yii framework unit tests.
- */
- abstract class TestCase extends \PHPUnit\Framework\TestCase
- {
- /**
- * Clean up after test.
- * By default the application created with [[mockApplication]] will be destroyed.
- */
- protected function tearDown()
- {
- parent::tearDown();
- $this->destroyApplication();
- }
- protected function mockWebApplication($config = [], $appClass = '\yii\web\Application')
- {
- new $appClass(ArrayHelper::merge([
- 'id' => 'testapp',
- 'basePath' => __DIR__,
- 'vendorPath' => dirname(__DIR__) . '/vendor',
- 'aliases' => [
- '@bower' => '@vendor/bower-asset',
- '@npm' => '@vendor/npm-asset',
- ],
- 'components' => [
- 'request' => [
- 'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
- 'scriptFile' => __DIR__ .'/index.php',
- 'scriptUrl' => '/index.php',
- ],
- ]
- ], $config));
- }
- /**
- * Destroys application in Yii::$app by setting it to null.
- */
- protected function destroyApplication()
- {
- Yii::$app = null;
- Yii::$container = new Container();
- }
- }
|