2018-07-08 20:50:19 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace common\tests\unit\tasks;
|
2018-07-08 20:50:19 +05:30
|
|
|
|
|
|
|
use common\tasks\ClearAccountSessions;
|
2019-02-21 01:28:52 +05:30
|
|
|
use common\tests\fixtures;
|
|
|
|
use common\tests\unit\TestCase;
|
2018-07-08 20:50:19 +05:30
|
|
|
use yii\queue\Queue;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \common\tasks\ClearAccountSessions
|
|
|
|
*/
|
|
|
|
class ClearAccountSessionsTest extends TestCase {
|
|
|
|
|
2019-05-14 04:28:29 +05:30
|
|
|
public function _fixtures(): array {
|
2018-07-08 20:50:19 +05:30
|
|
|
return [
|
|
|
|
'accounts' => fixtures\AccountFixture::class,
|
|
|
|
'oauthSessions' => fixtures\OauthSessionFixture::class,
|
|
|
|
'authSessions' => fixtures\AccountSessionFixture::class,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testExecute(): void {
|
2018-07-08 20:50:19 +05:30
|
|
|
/** @var \common\models\Account $bannedAccount */
|
|
|
|
$bannedAccount = $this->tester->grabFixture('accounts', 'banned-account');
|
2020-06-12 02:57:02 +05:30
|
|
|
$task = new ClearAccountSessions($bannedAccount->id);
|
2019-12-14 02:46:05 +05:30
|
|
|
$task->execute($this->createMock(Queue::class));
|
2018-07-08 20:50:19 +05:30
|
|
|
$this->assertEmpty($bannedAccount->sessions);
|
|
|
|
$this->assertEmpty($bannedAccount->oauthSessions);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|