mirror of
https://github.com/elyby/accounts.git
synced 2024-11-30 10:42:16 +05:30
Исправлена ошибка при попытке отправить сообщение в форму обратной связи, будучи залогиненным
This commit is contained in:
parent
9bdc9173c2
commit
85d109910f
@ -3,6 +3,7 @@ namespace api\models;
|
|||||||
|
|
||||||
use common\helpers\Error as E;
|
use common\helpers\Error as E;
|
||||||
use api\models\base\ApiForm;
|
use api\models\base\ApiForm;
|
||||||
|
use common\models\Account;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ErrorException;
|
use yii\base\ErrorException;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
@ -58,11 +59,13 @@ class FeedbackForm extends ApiForm {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function getAccount(): ?Account {
|
||||||
* @return \common\models\Account|null $account
|
$identity = Yii::$app->user->identity;
|
||||||
*/
|
if ($identity === null) {
|
||||||
protected function getAccount() {
|
return null;
|
||||||
return Yii::$app->user->identity;
|
}
|
||||||
|
|
||||||
|
return $identity->getAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
37
tests/codeception/api/functional/FeedbackCest.php
Normal file
37
tests/codeception/api/functional/FeedbackCest.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace tests\codeception\api\functional;
|
||||||
|
|
||||||
|
use tests\codeception\api\FunctionalTester;
|
||||||
|
|
||||||
|
class FeedbackCest {
|
||||||
|
|
||||||
|
public function testFeedbackWithoutAuth(FunctionalTester $I) {
|
||||||
|
$I->sendPOST('/feedback', [
|
||||||
|
'subject' => 'Test',
|
||||||
|
'email' => 'email@ely.by',
|
||||||
|
'type' => 0,
|
||||||
|
'message' => 'Hello world',
|
||||||
|
]);
|
||||||
|
$I->canSeeResponseCodeIs(200);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->canSeeResponseContainsJson([
|
||||||
|
'success' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFeedbackWithAuth(FunctionalTester $I) {
|
||||||
|
$I->amAuthenticated();
|
||||||
|
$I->sendPOST('/feedback', [
|
||||||
|
'subject' => 'Test',
|
||||||
|
'email' => 'email@ely.by',
|
||||||
|
'type' => 0,
|
||||||
|
'message' => 'Hello world',
|
||||||
|
]);
|
||||||
|
$I->canSeeResponseCodeIs(200);
|
||||||
|
$I->canSeeResponseIsJson();
|
||||||
|
$I->canSeeResponseContainsJson([
|
||||||
|
'success' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user