2016-07-17 22:08:04 +05:30
|
|
|
<?php
|
2019-08-02 05:59:20 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\_support\models\authentication;
|
2016-07-17 22:08:04 +05:30
|
|
|
|
|
|
|
use api\components\User\Component;
|
|
|
|
use api\models\authentication\LogoutForm;
|
2019-02-23 04:41:57 +05:30
|
|
|
use api\tests\unit\TestCase;
|
2016-07-17 22:08:04 +05:30
|
|
|
use common\models\AccountSession;
|
|
|
|
use Yii;
|
|
|
|
|
2016-10-29 03:17:31 +05:30
|
|
|
class LogoutFormTest extends TestCase {
|
2019-12-21 04:56:06 +05:30
|
|
|
|
|
|
|
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();
|
2016-07-17 22:08:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|