2016-11-24 02:11:33 +05:30
|
|
|
<?php
|
|
|
|
namespace codeception\console\unit\controllers;
|
|
|
|
|
2017-03-07 22:44:54 +05:30
|
|
|
use common\models\EmailActivation;
|
2017-09-27 22:22:28 +05:30
|
|
|
use common\models\MinecraftAccessKey;
|
2017-03-07 22:44:54 +05:30
|
|
|
use console\controllers\CleanupController;
|
|
|
|
use tests\codeception\common\fixtures\EmailActivationFixture;
|
2017-09-27 22:22:28 +05:30
|
|
|
use tests\codeception\common\fixtures\MinecraftAccessKeyFixture;
|
2016-11-24 02:11:33 +05:30
|
|
|
use tests\codeception\console\unit\TestCase;
|
2017-03-07 22:44:54 +05:30
|
|
|
use Yii;
|
2016-11-24 02:11:33 +05:30
|
|
|
|
|
|
|
class CleanupControllerTest extends TestCase {
|
|
|
|
|
2017-03-07 22:44:54 +05:30
|
|
|
public function _fixtures() {
|
|
|
|
return [
|
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2017-09-27 22:22:28 +05:30
|
|
|
'minecraftSessions' => MinecraftAccessKeyFixture::class
|
2017-03-07 22:44:54 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2017-09-27 22:22:28 +05:30
|
|
|
public function testActionEmailKeys() {
|
2017-03-07 22:44:54 +05:30
|
|
|
/** @var EmailActivation $expiredConfirmation */
|
|
|
|
$expiredConfirmation = $this->tester->grabFixture('emailActivations', 'deeplyExpiredConfirmation');
|
|
|
|
|
|
|
|
$controller = new CleanupController('cleanup', Yii::$app);
|
|
|
|
$this->assertEquals(0, $controller->actionEmailKeys());
|
|
|
|
|
2017-09-27 22:22:28 +05:30
|
|
|
$this->tester->cantSeeRecord(EmailActivation::class, ['key' => $expiredConfirmation->key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testActionMinecraftSessions() {
|
|
|
|
/** @var MinecraftAccessKey $expiredSession */
|
|
|
|
$expiredSession = $this->tester->grabFixture('minecraftSessions', 'expired-token');
|
|
|
|
|
|
|
|
$controller = new CleanupController('cleanup', Yii::$app);
|
|
|
|
$this->assertEquals(0, $controller->actionMinecraftSessions());
|
|
|
|
|
|
|
|
$this->tester->cantSeeRecord(MinecraftAccessKey::class, ['access_token' => $expiredSession->access_token]);
|
2017-03-07 22:44:54 +05:30
|
|
|
}
|
|
|
|
|
2016-11-24 02:11:33 +05:30
|
|
|
}
|