for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Anton Tuyakhov <[email protected]>
*/
namespace tuyakhov\braintree;
use Yii;
use yii\console\Application;
use yii\helpers\ArrayHelper;
* This is the base class for all unit tests.
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
* {@inheritdoc}
protected function setUp(): void
parent::setUp();
static::mockApplication();
}
protected function tearDown(): void
parent::tearDown();
static::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 static function mockApplication(array $config = [], string $appClass = Application::class)
$localConfigFile = __DIR__ . '/config/main-local.php';
new $appClass(
ArrayHelper::merge(
require __DIR__ . '/config/main.php',
is_file($localConfigFile) ? require $localConfigFile : [],
$config
)
);
* Destroys application in Yii::$app by setting it to null.
protected static function destroyApplication()
Yii::$app = null;