2016-11-24 02:11:33 +05:30
|
|
|
<?php
|
|
|
|
namespace codeception\console\unit\controllers;
|
|
|
|
|
|
|
|
use common\models\OauthAccessToken;
|
|
|
|
use console\controllers\CleanupController;
|
|
|
|
use tests\codeception\common\fixtures\OauthAccessTokenFixture;
|
|
|
|
use tests\codeception\console\unit\TestCase;
|
|
|
|
use Yii;
|
|
|
|
|
|
|
|
class CleanupControllerTest extends TestCase {
|
|
|
|
|
|
|
|
public function _fixtures() {
|
|
|
|
return [
|
|
|
|
'accessTokens' => OauthAccessTokenFixture::class,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testActionAccessTokens() {
|
|
|
|
/** @var OauthAccessToken $validAccessToken */
|
2016-11-24 03:29:44 +05:30
|
|
|
$validAccessToken = $this->tester->grabFixture('accessTokens', 'admin-test1');
|
2016-11-24 02:11:33 +05:30
|
|
|
/** @var OauthAccessToken $expiredAccessToken */
|
2016-11-24 03:29:44 +05:30
|
|
|
$expiredAccessToken = $this->tester->grabFixture('accessTokens', 'admin-test1-expired');
|
2016-11-24 02:11:33 +05:30
|
|
|
|
|
|
|
$controller = new CleanupController('cleanup', Yii::$app);
|
|
|
|
$this->assertEquals(0, $controller->actionAccessTokens());
|
|
|
|
|
|
|
|
$this->tester->canSeeRecord(OauthAccessToken::class, ['access_token' => $validAccessToken->access_token]);
|
|
|
|
$this->tester->cantSeeRecord(OauthAccessToken::class, ['access_token' => $expiredAccessToken->access_token]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|