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\models\Account;
|
|
|
|
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,
|
|
|
|
'minecraftAccessKeys' => fixtures\MinecraftAccessKeyFixture::class,
|
|
|
|
'authSessions' => fixtures\AccountSessionFixture::class,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateFromAccount() {
|
|
|
|
$account = new Account();
|
|
|
|
$account->id = 123;
|
|
|
|
$task = ClearAccountSessions::createFromAccount($account);
|
|
|
|
$this->assertSame(123, $task->accountId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExecute() {
|
|
|
|
/** @var \common\models\Account $bannedAccount */
|
|
|
|
$bannedAccount = $this->tester->grabFixture('accounts', 'banned-account');
|
|
|
|
$task = new ClearAccountSessions();
|
|
|
|
$task->accountId = $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->minecraftAccessKeys);
|
|
|
|
$this->assertEmpty($bannedAccount->oauthSessions);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|