mirror of
https://github.com/elyby/accounts.git
synced 2024-10-30 07:23:12 +05:30
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace api\tests\_support\models\authentication;
|
|
|
|
use api\components\User\Component;
|
|
use api\models\authentication\LogoutForm;
|
|
use api\tests\unit\TestCase;
|
|
use common\models\AccountSession;
|
|
use Yii;
|
|
|
|
class LogoutFormTest extends TestCase {
|
|
|
|
public function testNoActionWhenThereIsNoActiveSession() {
|
|
$userComp = $this->createPartialMock(Component::class, ['getActiveSession']);
|
|
$userComp->method('getActiveSession')->willReturn(null);
|
|
|
|
Yii::$app->set('user', $userComp);
|
|
|
|
$model = new LogoutForm();
|
|
$this->assertTrue($model->logout());
|
|
}
|
|
|
|
public function testActiveSessionShouldBeDeleted() {
|
|
$session = $this->createPartialMock(AccountSession::class, ['delete']);
|
|
$session->expects($this->once())->method('delete')->willReturn(true);
|
|
|
|
$userComp = $this->createPartialMock(Component::class, ['getActiveSession']);
|
|
$userComp->method('getActiveSession')->willReturn($session);
|
|
|
|
Yii::$app->set('user', $userComp);
|
|
|
|
$model = new LogoutForm();
|
|
$model->logout();
|
|
}
|
|
|
|
}
|