Rework tests structure. Upgrade codeception to 2.5.3. Merge params configuration into app configuration.

This commit is contained in:
ErickSkrauch
2019-02-20 22:58:52 +03:00
parent 2eacc581be
commit b05dc6816e
248 changed files with 1503 additions and 1339 deletions

View File

@ -1,9 +1,10 @@
<?php
declare(strict_types=1);
namespace api\modules\authserver;
use Yii;
use yii\base\BootstrapInterface;
use yii\base\InvalidConfigException;
use yii\web\NotFoundHttpException;
class Module extends \yii\base\Module implements BootstrapInterface {
@ -12,18 +13,6 @@ class Module extends \yii\base\Module implements BootstrapInterface {
public $defaultRoute = 'index';
/**
* @var string базовый домен, запросы на который этот модуль должен обрабатывать
*/
public $host = 'authserver.ely.by';
public function init() {
parent::init();
if ($this->host === null) {
throw new InvalidConfigException('base domain must be specified');
}
}
public function beforeAction($action) {
if (!parent::beforeAction($action)) {
return false;
@ -35,11 +24,12 @@ class Module extends \yii\base\Module implements BootstrapInterface {
}
/**
* @param \yii\base\Application $app the application currently running
* @param \yii\base\Application $app
*/
public function bootstrap($app) {
$legacyHost = $app->params['authserverHost'];
$app->getUrlManager()->addRules([
"//$this->host/$this->id/auth/<action>" => "$this->id/authentication/<action>",
"//{$legacyHost}/authserver/auth/<action>" => "{$this->id}/authentication/<action>",
], false);
}
@ -59,7 +49,7 @@ class Module extends \yii\base\Module implements BootstrapInterface {
* @throws NotFoundHttpException
*/
protected function checkHost() {
if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== $this->host) {
if (parse_url(Yii::$app->request->getHostInfo(), PHP_URL_HOST) !== Yii::$app->params['authserverHost']) {
throw new NotFoundHttpException();
}
}