diff --git a/.dockerignore b/.dockerignore index f22d37a..9690815 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,7 @@ # vendor будет заполнен уже внутри контейнера vendor # node_modules для этого контейнера не нужны -node_modules +frontend/node_modules # Все -local файлы */config/*-local.php diff --git a/api/controllers/OptionsController.php b/api/controllers/OptionsController.php index 2be2db8..4c230f9 100644 --- a/api/controllers/OptionsController.php +++ b/api/controllers/OptionsController.php @@ -3,28 +3,27 @@ namespace api\controllers; use Yii; use yii\helpers\ArrayHelper; -use yii\web\Response; class OptionsController extends Controller { public function behaviors() { return ArrayHelper::merge(parent::behaviors(), [ 'authenticator' => [ - 'except' => ['recaptcha-public-key'], + 'except' => ['index'], ], ]); } public function verbs() { return [ - 'recaptcha-public-key' => ['GET'], + 'index' => ['GET'], ]; } - public function actionRecaptchaPublicKey() { - Yii::$app->response->format = Response::FORMAT_RAW; - - return Yii::$app->reCaptcha->public; + public function actionIndex() { + return [ + 'reCaptchaPublicKey' => Yii::$app->reCaptcha->public, + ]; } } diff --git a/tests/codeception/api/_pages/OptionsRoute.php b/tests/codeception/api/_pages/OptionsRoute.php index 68ec646..e248ca0 100644 --- a/tests/codeception/api/_pages/OptionsRoute.php +++ b/tests/codeception/api/_pages/OptionsRoute.php @@ -8,8 +8,8 @@ use yii\codeception\BasePage; */ class OptionsRoute extends BasePage { - public function recaptchaPublicKey() { - $this->route = ['options/recaptcha-public-key']; + public function get() { + $this->route = ['options/index']; $this->actor->sendGET($this->getUrl()); } diff --git a/tests/codeception/api/functional/OptionsCest.php b/tests/codeception/api/functional/OptionsCest.php index f995da6..bf4cd21 100644 --- a/tests/codeception/api/functional/OptionsCest.php +++ b/tests/codeception/api/functional/OptionsCest.php @@ -18,11 +18,12 @@ class OptionsCest { public function testRecaptchaPublicKey(FunctionalTester $I) { $I->wantTo('Get recaptcha public key'); - $this->route->recaptchaPublicKey(); + $this->route->get(); $I->canSeeResponseCodeIs(200); - // TODO: эта проверка не проходит, т.к внутри почему-то после запроса не устанавливаются http заголовки - //$I->seeHttpHeader('Content-Type', 'text/html; charset=UTF-8'); - $I->canSeeResponseEquals('public-key'); + $I->canSeeResponseIsJson(); + $I->canSeeResponseContainsJson([ + 'reCaptchaPublicKey' => 'public-key', + ]); } }