mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Rework tests structure. Upgrade codeception to 2.5.3. Merge params configuration into app configuration.
This commit is contained in:
44
common/tests/unit/tasks/ClearAccountSessionsTest.php
Normal file
44
common/tests/unit/tasks/ClearAccountSessionsTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tests\unit\tasks;
|
||||
|
||||
use common\models\Account;
|
||||
use common\tasks\ClearAccountSessions;
|
||||
use common\tests\fixtures;
|
||||
use common\tests\unit\TestCase;
|
||||
use yii\queue\Queue;
|
||||
|
||||
/**
|
||||
* @covers \common\tasks\ClearAccountSessions
|
||||
*/
|
||||
class ClearAccountSessionsTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
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;
|
||||
$task->execute(mock(Queue::class));
|
||||
$this->assertEmpty($bannedAccount->sessions);
|
||||
$this->assertEmpty($bannedAccount->minecraftAccessKeys);
|
||||
$this->assertEmpty($bannedAccount->oauthSessions);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user