mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлен функционал очистки устаревших AccountSessions
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace codeception\console\unit\controllers;
|
||||
|
||||
use common\models\AccountSession;
|
||||
use common\models\EmailActivation;
|
||||
use common\models\MinecraftAccessKey;
|
||||
use console\controllers\CleanupController;
|
||||
use tests\codeception\common\fixtures\AccountSessionFixture;
|
||||
use tests\codeception\common\fixtures\EmailActivationFixture;
|
||||
use tests\codeception\common\fixtures\MinecraftAccessKeyFixture;
|
||||
use tests\codeception\console\unit\TestCase;
|
||||
@ -14,7 +16,8 @@ class CleanupControllerTest extends TestCase {
|
||||
public function _fixtures() {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
'minecraftSessions' => MinecraftAccessKeyFixture::class
|
||||
'minecraftSessions' => MinecraftAccessKeyFixture::class,
|
||||
'accountsSessions' => AccountSessionFixture::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -38,4 +41,19 @@ class CleanupControllerTest extends TestCase {
|
||||
$this->tester->cantSeeRecord(MinecraftAccessKey::class, ['access_token' => $expiredSession->access_token]);
|
||||
}
|
||||
|
||||
public function testActionWebSessions() {
|
||||
/** @var AccountSession $expiredSession */
|
||||
$expiredSession = $this->tester->grabFixture('accountsSessions', 'very-expired-session');
|
||||
/** @var AccountSession $notRefreshedSession */
|
||||
$notRefreshedSession = $this->tester->grabFixture('accountsSessions', 'not-refreshed-session');
|
||||
$totalSessionsCount = AccountSession::find()->count();
|
||||
|
||||
$controller = new CleanupController('cleanup', Yii::$app);
|
||||
$this->assertEquals(0, $controller->actionWebSessions());
|
||||
|
||||
$this->tester->cantSeeRecord(AccountSession::class, ['id' => $expiredSession->id]);
|
||||
$this->tester->cantSeeRecord(AccountSession::class, ['id' => $notRefreshedSession->id]);
|
||||
$this->assertEquals($totalSessionsCount - 2, AccountSession::find()->count());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user