Восстановлен запуск тестов

Загрузчик конфигов выделен в отдельный класс
authserverHost выделена в params
Исправлены некоторые common.unit тесты, т.к. наследовались не от того базового класса
This commit is contained in:
ErickSkrauch 2016-09-19 01:01:19 +03:00
parent 54485b2271
commit df6d319187
35 changed files with 147 additions and 190 deletions

View File

@ -1,3 +1,4 @@
<?php <?php
return [ return [
'authserverHost' => getenv('AUTHSERVER_HOST'),
]; ];

View File

@ -25,7 +25,7 @@ class SessionController extends ApiController {
$behaviors['rateLimiting'] = [ $behaviors['rateLimiting'] = [
'class' => RateLimiter::class, 'class' => RateLimiter::class,
'only' => ['has-joined', 'has-joined-legacy'], 'only' => ['has-joined', 'has-joined-legacy'],
'authserverDomain' => getenv('AUTHSERVER_HOST'), 'authserverDomain' => Yii::$app->params['authserverHost'],
]; ];
return $behaviors; return $behaviors;

View File

@ -41,8 +41,7 @@ class RateLimiter extends \yii\filters\RateLimiter {
* @inheritdoc * @inheritdoc
*/ */
public function checkRateLimit($user, $request, $response, $action) { public function checkRateLimit($user, $request, $response, $action) {
// TODO: теперь в authserverDomain хранится hostname без schema, а getHostInfo() возвращает с http(s). if (parse_url($request->getHostInfo(), PHP_URL_HOST) === $this->authserverDomain) {
if ($request->getHostInfo() === $this->authserverDomain) {
return; return;
} }

View File

@ -3,14 +3,12 @@ require __DIR__ . '/../../vendor/autoload.php';
defined('YII_DEBUG') or define('YII_DEBUG', (boolean)getenv('YII_DEBUG')); defined('YII_DEBUG') or define('YII_DEBUG', (boolean)getenv('YII_DEBUG'));
defined('YII_ENV') or define('YII_ENV', getenv('YII_ENV')); defined('YII_ENV') or define('YII_ENV', getenv('YII_ENV'));
defined('YII_APPLICATION_TYPE') or define('YII_APPLICATION_TYPE', 'web');
defined('YII_APPLICATION_MODULE') or define('YII_APPLICATION_MODULE', 'api');
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/bootstrap.php'; require __DIR__ . '/../../common/config/bootstrap.php';
require __DIR__ . '/../config/bootstrap.php'; require __DIR__ . '/../config/bootstrap.php';
$config = require __DIR__ . './../../common/config/config-loader.php'; $config = \common\config\ConfigLoader::load('api');
$application = new yii\web\Application($config); $application = new yii\web\Application($config);
$application->run(); $application->run();

View File

@ -1 +1 @@
main-local.php config-local.php

View File

@ -0,0 +1,65 @@
<?php
namespace common\config;
use yii\helpers\ArrayHelper;
class ConfigLoader {
/*
* TODO: В PHP 7.1 следует сделать её protected
*/
const ROOT_PATH = __DIR__ . '/../..';
private $application;
public function __construct(string $application) {
$this->application = $application;
}
public function getEnvironment() : string {
return YII_ENV;
}
public function getConfig() : array {
$toMerge = [
require __DIR__ . '/config.php',
];
// Общие окружение-зависимые настройки
$path = __DIR__ . '/config-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Общие локальные настройки
$path = __DIR__ . '/config-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения
$path = self::ROOT_PATH . '/' . $this->application . '/config/config.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения для действующего окружения
$path = self::ROOT_PATH . '/' . $this->application . '/config/main-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Локальные настройки конкретного приложения
$path = self::ROOT_PATH . '/' . $this->application . '/config/config-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
return ArrayHelper::merge(...$toMerge);
}
public static function load(string $application) : array {
return (new static($application))->getConfig();
}
}

View File

@ -1,43 +0,0 @@
<?php
use yii\helpers\ArrayHelper;
$rootPath = __DIR__ . '/../..';
$toMerge = [
require __DIR__ . '/main.php',
];
// Общие окружение-зависимые настройки
$path = __DIR__ . '/common-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Общие локальные настройки
$path = __DIR__ . '/common-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Настройки конкретного приложения для действующего окружения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main-' . YII_ENV . '.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// Локальные настройки конкретного приложения
$path = $rootPath . '/' . YII_APPLICATION_MODULE . '/config/main-local.php';
if (file_exists($path)) {
$toMerge[] = require $path;
}
// не оставляем глобальных переменных, ну кроме $toMerge, хех
unset($path, $rootPath);
return ArrayHelper::merge(...$toMerge);

View File

@ -1,24 +1,26 @@
<?php <?php
use Codeception\Configuration;
use Codeception\Specify\Config;
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV_TEST') or define('YII_ENV_TEST', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); defined('API_ENTRY_URL') or define('API_ENTRY_URL', parse_url(Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
defined('API_ENTRY_FILE') or define('API_ENTRY_FILE', __DIR__ . '/../../../api/web/index.php');
defined('API_ENTRY_URL') or define('API_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH)); require_once __DIR__ . '/../../../vendor/autoload.php';
defined('API_ENTRY_FILE') or define('API_ENTRY_FILE', YII_APP_BASE_PATH . '/api/web/index-test.php'); require_once __DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php';
require_once __DIR__ . '/../../../common/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); require_once __DIR__ . '/../../../api/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
require_once(YII_APP_BASE_PATH . '/api/config/bootstrap.php');
// set correct script paths // set correct script paths
// the entry script file path for functional tests // the entry script file path for functional tests
$_SERVER['SCRIPT_FILENAME'] = API_ENTRY_FILE; $_SERVER['SCRIPT_FILENAME'] = API_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = API_ENTRY_URL; $_SERVER['SCRIPT_NAME'] = API_ENTRY_URL;
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST); $_SERVER['SERVER_NAME'] = parse_url(Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; $_SERVER['SERVER_PORT'] = parse_url(Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
Yii::setAlias('@tests', dirname(dirname(__DIR__))); Yii::setAlias('@tests', dirname(dirname(__DIR__)));
\Codeception\Specify\Config::setDeepClone(false); Config::setDeepClone(false);

View File

@ -12,9 +12,7 @@ settings:
memory_limit: 1024M memory_limit: 1024M
log: true log: true
config: config:
# the entry script URL (with host info) for functional tests test_entry_url: http://localhost:8080/api/web/index.php
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://localhost:8080/api/web/index-test.php
coverage: coverage:
enabled: true enabled: true
remote: true remote: true
@ -26,4 +24,4 @@ coverage:
- ../../../api/mails/* - ../../../api/mails/*
- ../../../api/web/* - ../../../api/web/*
- ../../../api/runtime/* - ../../../api/runtime/*
c3url: 'http://localhost:8080/api/web/index-test.php' c3url: 'http://localhost:8080/api/web/index.php'

View File

@ -1,5 +1,4 @@
<?php <?php
new yii\web\Application(require __DIR__ . '/../../config/api/functional.php');
new yii\web\Application(require(dirname(dirname(__DIR__)) . '/config/api/functional.php'));
\Codeception\Util\Autoload::registerSuffix('Steps', __DIR__ . DIRECTORY_SEPARATOR); \Codeception\Util\Autoload::registerSuffix('Steps', __DIR__ . DIRECTORY_SEPARATOR);

View File

@ -1,6 +1,7 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace tests\codeception\api\models\authentication;
use api\components\ReCaptcha\Validator;
use api\models\authentication\RegistrationForm; use api\models\authentication\RegistrationForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\Account; use common\models\Account;
@ -25,6 +26,11 @@ class RegistrationFormTest extends DbTestCase {
return 'testing_message.eml'; return 'testing_message.eml';
}; };
$this->mockRequest(); $this->mockRequest();
Yii::$container->set(Validator::class, new class extends Validator {
public function validateValue($value) {
return null;
}
});
} }
protected function tearDown() { protected function tearDown() {

View File

@ -1,6 +1,7 @@
<?php <?php
namespace tests\codeception\api\models\authentication; namespace tests\codeception\api\models\authentication;
use api\components\ReCaptcha\Validator;
use api\models\authentication\RepeatAccountActivationForm; use api\models\authentication\RepeatAccountActivationForm;
use Codeception\Specify; use Codeception\Specify;
use common\models\EmailActivation; use common\models\EmailActivation;
@ -23,6 +24,11 @@ class RepeatAccountActivationFormTest extends DbTestCase {
$mailer->fileTransportCallback = function () { $mailer->fileTransportCallback = function () {
return 'testing_message.eml'; return 'testing_message.eml';
}; };
Yii::$container->set(Validator::class, new class extends Validator {
public function validateValue($value) {
return null;
}
});
} }
protected function tearDown() { protected function tearDown() {

View File

@ -24,6 +24,9 @@ class RateLimiterTest extends TestCase {
/** @var RateLimiter|\PHPUnit_Framework_MockObject_MockObject $filter */ /** @var RateLimiter|\PHPUnit_Framework_MockObject_MockObject $filter */
$filter = $this->getMockBuilder(RateLimiter::class) $filter = $this->getMockBuilder(RateLimiter::class)
->setConstructorArgs([[
'authserverDomain' => Yii::$app->params['authserverHost']
]])
->setMethods(['getServer']) ->setMethods(['getServer'])
->getMock(); ->getMock();
@ -54,7 +57,9 @@ class RateLimiterTest extends TestCase {
->method('getHostInfo') ->method('getHostInfo')
->will($this->returnValue('http://authserver.ely.by')); ->will($this->returnValue('http://authserver.ely.by'));
$filter = new RateLimiter(); $filter = new RateLimiter([
'authserverDomain' => Yii::$app->params['authserverHost']
]);
$filter->checkRateLimit(null, $request, null, null); $filter->checkRateLimit(null, $request, null, null);
} }
@ -86,6 +91,7 @@ class RateLimiterTest extends TestCase {
$filter = $this->getMockBuilder(RateLimiter::class) $filter = $this->getMockBuilder(RateLimiter::class)
->setConstructorArgs([[ ->setConstructorArgs([[
'limit' => 3, 'limit' => 3,
'authserverDomain' => Yii::$app->params['authserverHost'],
]]) ]])
->setMethods(['getServer']) ->setMethods(['getServer'])
->getMock(); ->getMock();

View File

@ -1,19 +1,10 @@
<?php <?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV_TEST') or define('YII_ENV_TEST', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php';
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); require_once __DIR__ . '/../../../common/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
Yii::setAlias('@tests', dirname(dirname(__DIR__))); Yii::setAlias('@tests', dirname(dirname(__DIR__)));

View File

@ -1,21 +1,10 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
require_once __DIR__ . '/_bootstrap.php'; require_once __DIR__ . '/_bootstrap.php';
$config = yii\helpers\ArrayHelper::merge( $config = yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'), \common\config\ConfigLoader::load('console'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'), require(__DIR__ . '/../config/config.php')
require(YII_APP_BASE_PATH . '/console/config/main.php'),
require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config/config.php')
); );
$application = new yii\console\Application($config); $application = new yii\console\Application($config);

View File

@ -1,20 +0,0 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright (c) 2008 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal

View File

@ -1,12 +1,11 @@
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV_TEST') or define('YII_ENV_TEST', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php';
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); require_once __DIR__ . '/../../../common/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
// set correct script paths // set correct script paths
$_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['SERVER_NAME'] = 'localhost';

View File

@ -3,7 +3,7 @@ namespace codeception\common\unit\behaviors;
use Codeception\Specify; use Codeception\Specify;
use common\behaviors\PrimaryKeyValueBehavior; use common\behaviors\PrimaryKeyValueBehavior;
use tests\codeception\api\unit\TestCase; use tests\codeception\common\unit\TestCase;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
class PrimaryKeyValueBehaviorTest extends TestCase { class PrimaryKeyValueBehaviorTest extends TestCase {

View File

@ -6,7 +6,7 @@ use common\models\confirmations\ForgotPassword;
use common\models\confirmations\RegistrationConfirmation; use common\models\confirmations\RegistrationConfirmation;
use common\models\EmailActivation; use common\models\EmailActivation;
use tests\codeception\common\fixtures\EmailActivationFixture; use tests\codeception\common\fixtures\EmailActivationFixture;
use tests\codeception\console\unit\DbTestCase; use tests\codeception\common\unit\DbTestCase;
class EmailActivationTest extends DbTestCase { class EmailActivationTest extends DbTestCase {
use Specify; use Specify;

View File

@ -10,6 +10,6 @@ return [
], ],
], ],
'params' => [ 'params' => [
'authserverDomain' => 'http://authserver.ely.by', 'authserverHost' => 'authserver.ely.by',
], ],
]; ];

View File

@ -2,16 +2,9 @@
$_SERVER['SCRIPT_FILENAME'] = API_ENTRY_FILE; $_SERVER['SCRIPT_FILENAME'] = API_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = API_ENTRY_URL; $_SERVER['SCRIPT_NAME'] = API_ENTRY_URL;
/**
* Application configuration for api functional tests
*/
return yii\helpers\ArrayHelper::merge( return yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'), \common\config\ConfigLoader::load('api'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'), require(YII_APP_BASE_PATH . '/api/config/main.php'), require __DIR__ . '/../config.php',
require(YII_APP_BASE_PATH . '/api/config/main-local.php'), require __DIR__ . '/../functional.php',
require(dirname(__DIR__) . '/config.php'), require __DIR__ . '/config.php'
require(dirname(__DIR__) . '/functional.php'),
require(__DIR__ . '/config.php'),
[
]
); );

View File

@ -1,15 +1,7 @@
<?php <?php
/**
* Application configuration for api unit tests
*/
return yii\helpers\ArrayHelper::merge( return yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'), \common\config\ConfigLoader::load('api'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'), require(YII_APP_BASE_PATH . '/api/config/main.php'), require __DIR__ . '/../config.php',
require(YII_APP_BASE_PATH . '/api/config/main-local.php'), require __DIR__ . '/../unit.php',
require(dirname(__DIR__) . '/config.php'), require __DIR__ . '/config.php'
require(dirname(__DIR__) . '/unit.php'),
require(__DIR__ . '/config.php'),
[
]
); );

View File

@ -1,12 +1,8 @@
<?php <?php
/**
* Application config for common unit tests
*/
return yii\helpers\ArrayHelper::merge( return yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'), \common\config\ConfigLoader::load('common'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'), require __DIR__ . '/../config.php',
require(dirname(__DIR__) . '/config.php'), require __DIR__ . '/../unit.php',
require(dirname(__DIR__) . '/unit.php'),
[ [
'id' => 'app-common', 'id' => 'app-common',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),

View File

@ -3,7 +3,7 @@ return [
'language' => 'en-US', 'language' => 'en-US',
'controllerMap' => [ 'controllerMap' => [
'fixture' => [ 'fixture' => [
'class' => 'yii\faker\FixtureController', 'class' => yii\faker\FixtureController::class,
'fixtureDataPath' => '@tests/codeception/common/fixtures/data', 'fixtureDataPath' => '@tests/codeception/common/fixtures/data',
'templatePath' => '@tests/codeception/common/templates/fixtures', 'templatePath' => '@tests/codeception/common/templates/fixtures',
'namespace' => 'tests\codeception\common\fixtures', 'namespace' => 'tests\codeception\common\fixtures',

View File

@ -1,14 +1,6 @@
<?php <?php
/**
* Application configuration for console unit tests
*/
return yii\helpers\ArrayHelper::merge( return yii\helpers\ArrayHelper::merge(
require(YII_APP_BASE_PATH . '/common/config/main.php'), \common\config\ConfigLoader::load('console'),
require(YII_APP_BASE_PATH . '/common/config/main-local.php'), require __DIR__ . '/../config.php',
require(YII_APP_BASE_PATH . '/console/config/main.php'), require __DIR__ . '/../unit.php'
require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
require(dirname(__DIR__) . '/config.php'),
require(dirname(__DIR__) . '/unit.php'),
[
]
); );

View File

@ -1,18 +1,12 @@
<?php <?php
/**
* Application configuration shared by all applications functional tests
*/
return [ return [
'components' => [ 'components' => [
'request' => [ 'request' => [
// it's not recommended to run functional tests with CSRF validation enabled // it's not recommended to run functional tests with CSRF validation enabled
// TODO: у нас вроде и без того нет проверки csrf
'enableCsrfValidation' => false, 'enableCsrfValidation' => false,
'enableCookieValidation' => false,
// but if you absolutely need it set cookie domain to localhost // but if you absolutely need it set cookie domain to localhost
/*
'csrfCookie' => [
'domain' => 'localhost',
],
*/
], ],
], ],
]; ];

View File

@ -1,7 +1,4 @@
<?php <?php
/**
* Application configuration shared by all applications unit tests
*/
return [ return [
]; ];

View File

@ -1,13 +1,12 @@
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV_TEST') or define('YII_ENV_TEST', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); require_once __DIR__ . '/../../../vendor/autoload.php';
require_once __DIR__ . '/../../../vendor/yiisoft/yii2/Yii.php';
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); require_once __DIR__ . '/../../../common/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); require_once __DIR__ . '/../../../console/config/bootstrap.php';
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
require_once(YII_APP_BASE_PATH . '/console/config/bootstrap.php');
// set correct script paths // set correct script paths
$_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['SERVER_NAME'] = 'localhost';

4
yii
View File

@ -4,14 +4,12 @@ require(__DIR__ . '/vendor/autoload.php');
defined('YII_DEBUG') or define('YII_DEBUG', (boolean)getenv('YII_DEBUG')); defined('YII_DEBUG') or define('YII_DEBUG', (boolean)getenv('YII_DEBUG'));
defined('YII_ENV') or define('YII_ENV', getenv('YII_ENV')); defined('YII_ENV') or define('YII_ENV', getenv('YII_ENV'));
defined('YII_APPLICATION_TYPE') or define('YII_APPLICATION_TYPE', 'cli');
defined('YII_APPLICATION_MODULE') or define('YII_APPLICATION_MODULE', 'console');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/common/config/bootstrap.php'); require(__DIR__ . '/common/config/bootstrap.php');
require(__DIR__ . '/console/config/bootstrap.php'); require(__DIR__ . '/console/config/bootstrap.php');
$config = require __DIR__ . '/common/config/config-loader.php'; $config = \common\config\ConfigLoader::load('console');
$application = new yii\console\Application($config); $application = new yii\console\Application($config);
$exitCode = $application->run(); $exitCode = $application->run();