for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace yii2mod\enum\tests;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the base class for all yii framework unit tests.
*/
class TestCase extends \PHPUnit\Framework\TestCase
{
protected function setUp()
parent::setUp();
$this->mockApplication();
}
protected function tearDown()
$this->destroyApplication();
* Populates Yii::$app with a new application
* The application will be destroyed on tearDown() automatically.
*
* @param array $config The application configuration, if needed
* @param string $appClass name of the application class to create
protected function mockApplication($config = [], $appClass = '\yii\console\Application')
new $appClass(ArrayHelper::merge([
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => $this->getVendorPath(),
'components' => [
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages', // if advanced application, set @frontend/messages
'sourceLanguage' => 'en',
],
], $config));
* @return string vendor path
protected function getVendorPath()
return dirname(__DIR__) . '/vendor';
* Destroys application in Yii::$app by setting it to null.
protected function destroyApplication()
Yii::$app = null;