Merge branch 'develop'

This commit is contained in:
ErickSkrauch 2017-11-03 16:15:34 +03:00
commit c07a3cb057
3 changed files with 46 additions and 6 deletions

View File

@ -3,6 +3,7 @@ namespace api\models;
use common\helpers\Error as E;
use api\models\base\ApiForm;
use common\models\Account;
use Yii;
use yii\base\ErrorException;
use yii\base\InvalidConfigException;
@ -58,11 +59,13 @@ class FeedbackForm extends ApiForm {
return true;
}
/**
* @return \common\models\Account|null $account
*/
protected function getAccount() {
return Yii::$app->user->identity;
protected function getAccount(): ?Account {
$identity = Yii::$app->user->identity;
if ($identity === null) {
return null;
}
return $identity->getAccount();
}
}

View File

@ -1,6 +1,6 @@
<?php
return [
'version' => '1.1.20',
'version' => '1.1.21',
'vendorPath' => dirname(__DIR__, 2) . '/vendor',
'components' => [
'cache' => [

View 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,
]);
}
}