1
0
mirror of https://github.com/elyby/accounts.git synced 2025-05-31 14:11:46 +05:30
Files
api
common
console
data
docker
tests
codeception
_output
api
_output
_pages
_support
functional
unit
components
filters
models
authentication
ConfirmEmailFormTest.php
ForgotPasswordFormTest.php
LoginFormTest.php
LogoutFormTest.php
RecoverPasswordFormTest.php
RefreshTokenFormTest.php
RegistrationFormTest.php
RepeatAccountActivationFormTest.php
base
profile
AccountIdentityTest.php
FeedbackFormTest.php
modules
traits
validators
TestCase.php
_bootstrap.php
.gitignore
_bootstrap.php
codeception.yml
functional.suite.yml
unit.suite.yml
bin
common
config
console
codeception.yml
docker-compose.yml
php.sh
run-tests.sh
.dockerignore
.env-dist
.gitignore
.gitlab-ci.yml
Dockerfile
Dockerfile-dev
README.md
autocompletion.php
composer.json
docker-compose.dev.yml
docker-compose.prod.yml
yii
accounts/tests/codeception/api/unit/models/authentication/RefreshTokenFormTest.php
2016-10-29 00:47:31 +03:00

51 lines
1.7 KiB
PHP

<?php
namespace codeception\api\unit\models\authentication;
use api\components\User\RenewResult;
use api\models\authentication\RefreshTokenForm;
use Codeception\Specify;
use common\models\AccountSession;
use tests\codeception\api\unit\TestCase;
use tests\codeception\common\fixtures\AccountSessionFixture;
class RefreshTokenFormTest extends TestCase {
use Specify;
public function _fixtures() {
return [
'sessions' => AccountSessionFixture::class,
];
}
public function testValidateRefreshToken() {
$this->specify('error.refresh_token_not_exist if passed token not exists', function() {
/** @var RefreshTokenForm $model */
$model = new class extends RefreshTokenForm {
public function getSession() {
return null;
}
};
$model->validateRefreshToken();
expect($model->getErrors('refresh_token'))->equals(['error.refresh_token_not_exist']);
});
$this->specify('no errors if token exists', function() {
/** @var RefreshTokenForm $model */
$model = new class extends RefreshTokenForm {
public function getSession() {
return new AccountSession();
}
};
$model->validateRefreshToken();
expect($model->getErrors('refresh_token'))->isEmpty();
});
}
public function testRenew() {
$model = new RefreshTokenForm();
$model->refresh_token = $this->tester->grabFixture('sessions', 'admin')['refresh_token'];
$this->assertInstanceOf(RenewResult::class, $model->renew());
}
}