mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Upgrade Codeception to 3 version. Remove codeception/verify.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace api\tests\unit;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use Mockery;
|
||||
|
||||
class TestCase extends \Codeception\Test\Unit {
|
||||
class TestCase extends Unit {
|
||||
|
||||
/**
|
||||
* @var \api\tests\UnitTester
|
||||
@@ -22,7 +25,7 @@ class TestCase extends \Codeception\Test\Unit {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ class ComponentTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
/**
|
||||
* @var Component|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var Component|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $component;
|
||||
|
||||
@@ -30,7 +30,7 @@ class ComponentTest extends TestCase {
|
||||
$this->component = new Component($this->getComponentConfig());
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'sessions' => AccountSessionFixture::class,
|
||||
@@ -115,7 +115,7 @@ class ComponentTest extends TestCase {
|
||||
$result = $this->component->createJwtAuthenticationToken($account, true);
|
||||
$this->component->logout();
|
||||
|
||||
/** @var Component|\PHPUnit_Framework_MockObject_MockObject $component */
|
||||
/** @var Component|\PHPUnit\Framework\MockObject\MockObject $component */
|
||||
$component = $this->getMockBuilder(Component::class)
|
||||
->setMethods(['getIsGuest'])
|
||||
->setConstructorArgs([$this->getComponentConfig()])
|
||||
|
@@ -20,7 +20,7 @@ class NginxCacheTest extends TestCase {
|
||||
}
|
||||
|
||||
private function testAfterActionInternal($ruleConfig, $expected) {
|
||||
/** @var HeaderCollection|\PHPUnit_Framework_MockObject_MockObject $headers */
|
||||
/** @var HeaderCollection|\PHPUnit\Framework\MockObject\MockObject $headers */
|
||||
$headers = $this->getMockBuilder(HeaderCollection::class)
|
||||
->setMethods(['set'])
|
||||
->getMock();
|
||||
@@ -29,7 +29,7 @@ class NginxCacheTest extends TestCase {
|
||||
->method('set')
|
||||
->with('X-Accel-Expires', $expected);
|
||||
|
||||
/** @var Request|\PHPUnit_Framework_MockObject_MockObject $request */
|
||||
/** @var Request|\PHPUnit\Framework\MockObject\MockObject $request */
|
||||
$request = $this->getMockBuilder(Request::class)
|
||||
->setMethods(['getHeaders'])
|
||||
->getMock();
|
||||
@@ -40,7 +40,7 @@ class NginxCacheTest extends TestCase {
|
||||
|
||||
Yii::$app->set('response', $request);
|
||||
|
||||
/** @var Controller|\PHPUnit_Framework_MockObject_MockObject $controller */
|
||||
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject $controller */
|
||||
$controller = $this->getMockBuilder(Controller::class)
|
||||
->setConstructorArgs(['mock', Yii::$app])
|
||||
->getMock();
|
||||
|
@@ -19,7 +19,7 @@ class FeedbackFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testSendMessageWithEmail() {
|
||||
/** @var FeedbackForm|\PHPUnit_Framework_MockObject_MockObject $model */
|
||||
/** @var FeedbackForm|\PHPUnit\Framework\MockObject\MockObject $model */
|
||||
$model = $this->getMockBuilder(FeedbackForm::class)
|
||||
->setMethods(['getAccount'])
|
||||
->setConstructorArgs([[
|
||||
|
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
namespace codeception\api\unit\models;
|
||||
|
||||
use api\components\User\IdentityInterface;
|
||||
use api\components\User\Jwt;
|
||||
use api\components\User\JwtIdentity;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\tests\_support\ProtectedCaller;
|
||||
use common\tests\fixtures\AccountFixture;
|
||||
use Emarref\Jwt\Claim;
|
||||
@@ -14,7 +12,6 @@ use Emarref\Jwt\Token;
|
||||
use Yii;
|
||||
|
||||
class JwtIdentityTest extends TestCase {
|
||||
use Specify;
|
||||
use ProtectedCaller;
|
||||
|
||||
public function _fixtures(): array {
|
||||
@@ -26,7 +23,6 @@ class JwtIdentityTest extends TestCase {
|
||||
public function testFindIdentityByAccessToken() {
|
||||
$token = $this->generateToken();
|
||||
$identity = JwtIdentity::findIdentityByAccessToken($token);
|
||||
$this->assertInstanceOf(IdentityInterface::class, $identity);
|
||||
$this->assertSame($token, $identity->getId());
|
||||
$this->assertSame($this->tester->grabFixture('accounts', 'admin')['id'], $identity->getAccount()->id);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class ConfirmEmailFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
];
|
||||
|
@@ -4,7 +4,6 @@ namespace codeception\api\unit\models\authentication;
|
||||
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
|
||||
use api\models\authentication\ForgotPasswordForm;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use common\tasks\SendPasswordRecoveryEmail;
|
||||
@@ -14,7 +13,6 @@ use GuzzleHttp\ClientInterface;
|
||||
use Yii;
|
||||
|
||||
class ForgotPasswordFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
@@ -25,7 +23,7 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
@@ -104,12 +102,13 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SendPasswordRecoveryEmail $job
|
||||
* @param \yii\queue\JobInterface $job
|
||||
* @param Account $account
|
||||
* @param EmailActivation $activation
|
||||
*/
|
||||
private function assertTaskCreated($job, Account $account, EmailActivation $activation) {
|
||||
$this->assertInstanceOf(SendPasswordRecoveryEmail::class, $job);
|
||||
/** @var SendPasswordRecoveryEmail $job */
|
||||
$this->assertSame($account->username, $job->username);
|
||||
$this->assertSame($account->email, $job->email);
|
||||
$this->assertSame($account->lang, $job->locale);
|
||||
|
@@ -25,7 +25,7 @@ class LoginFormTest extends TestCase {
|
||||
$_SERVER['REMOTE_ADDR'] = $this->originalRemoteAddr;
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
];
|
||||
|
@@ -27,7 +27,7 @@ class LogoutFormTest extends TestCase {
|
||||
Yii::$app->set('user', $userComp);
|
||||
|
||||
$model = new LogoutForm();
|
||||
expect($model->logout())->true();
|
||||
$this->assertTrue($model->logout());
|
||||
});
|
||||
|
||||
$this->specify('if active session is presented, then delete should be called', function() {
|
||||
|
@@ -4,15 +4,13 @@ namespace api\tests\_support\models\authentication;
|
||||
use api\components\User\AuthenticationResult;
|
||||
use api\models\authentication\RecoverPasswordForm;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class RecoverPasswordFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
];
|
||||
|
@@ -11,7 +11,7 @@ use common\tests\fixtures\AccountSessionFixture;
|
||||
class RefreshTokenFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'sessions' => AccountSessionFixture::class,
|
||||
];
|
||||
|
@@ -30,7 +30,7 @@ class RegistrationFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@@ -24,7 +24,7 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'activations' => EmailActivationFixture::class,
|
||||
@@ -35,21 +35,21 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
$this->specify('error.email_not_found if passed valid email, but it don\'t exists in database', function() {
|
||||
$model = new RepeatAccountActivationForm(['email' => 'me-is-not@exists.net']);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->equals(['error.email_not_found']);
|
||||
$this->assertSame(['error.email_not_found'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('error.account_already_activated if passed valid email, but account already activated', function() {
|
||||
$fixture = $this->tester->grabFixture('accounts', 'admin');
|
||||
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->equals(['error.account_already_activated']);
|
||||
$this->assertSame(['error.account_already_activated'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed valid email for not activated account', function() {
|
||||
$fixture = $this->tester->grabFixture('accounts', 'not-activated-account');
|
||||
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->isEmpty();
|
||||
$this->assertEmpty($model->getErrors('email'));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
$fixture = $this->tester->grabFixture('activations', 'freshRegistrationConfirmation');
|
||||
$model = $this->createModel(['emailKey' => $fixture['key']]);
|
||||
$model->validateExistsActivation('email');
|
||||
expect($model->getErrors('email'))->equals(['error.recently_sent_message']);
|
||||
$this->assertSame(['error.recently_sent_message'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed email has expired activation message', function() {
|
||||
$fixture = $this->tester->grabFixture('activations', 'oldRegistrationConfirmation');
|
||||
$model = $this->createModel(['emailKey' => $fixture['key']]);
|
||||
$model->validateExistsActivation('email');
|
||||
expect($model->getErrors('email'))->isEmpty();
|
||||
$this->assertEmpty($model->getErrors('email'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class ChangeEmailFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@@ -11,7 +11,7 @@ use common\tests\fixtures\UsernameHistoryFixture;
|
||||
|
||||
class ChangeUsernameFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'history' => UsernameHistoryFixture::class,
|
||||
|
@@ -12,7 +12,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class SendEmailVerificationFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@@ -14,7 +14,7 @@ use yii\validators\EmailValidator;
|
||||
|
||||
class SendNewEmailVerificationFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@@ -15,7 +15,7 @@ use Ramsey\Uuid\Uuid;
|
||||
class AuthenticationFormTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'minecraftAccessKeys' => MinecraftAccessKeyFixture::class,
|
||||
@@ -111,7 +111,7 @@ class AuthenticationFormTest extends TestCase {
|
||||
}
|
||||
|
||||
private function createAuthForm($status = Account::STATUS_ACTIVE) {
|
||||
/** @var LoginForm|\PHPUnit_Framework_MockObject_MockObject $loginForm */
|
||||
/** @var LoginForm|\PHPUnit\Framework\MockObject\MockObject $loginForm */
|
||||
$loginForm = $this->getMockBuilder(LoginForm::class)
|
||||
->setMethods(['getAccount'])
|
||||
->getMock();
|
||||
@@ -126,7 +126,7 @@ class AuthenticationFormTest extends TestCase {
|
||||
->method('getAccount')
|
||||
->will($this->returnValue($account));
|
||||
|
||||
/** @var AuthenticationForm|\PHPUnit_Framework_MockObject_MockObject $authForm */
|
||||
/** @var AuthenticationForm|\PHPUnit\Framework\MockObject\MockObject $authForm */
|
||||
$authForm = $this->getMockBuilder(AuthenticationForm::class)
|
||||
->setMethods(['createLoginForm', 'createMinecraftAccessToken'])
|
||||
->getMock();
|
||||
|
@@ -24,7 +24,7 @@ class BanFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testBan() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
/** @var Account|\PHPUnit\Framework\MockObject\MockObject $account */
|
||||
$account = $this->getMockBuilder(Account::class)
|
||||
->setMethods(['save'])
|
||||
->getMock();
|
||||
|
@@ -23,7 +23,7 @@ class PardonFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testPardon() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
/** @var Account|\PHPUnit\Framework\MockObject\MockObject $account */
|
||||
$account = $this->getMockBuilder(Account::class)
|
||||
->setMethods(['save'])
|
||||
->getMock();
|
||||
|
@@ -3,14 +3,12 @@ namespace api\tests\_support\traits;
|
||||
|
||||
use api\tests\unit\TestCase;
|
||||
use api\traits\AccountFinder;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\tests\fixtures\AccountFixture;
|
||||
|
||||
class AccountFinderTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
];
|
||||
|
@@ -3,7 +3,6 @@ namespace codeception\api\unit\validators;
|
||||
|
||||
use api\tests\unit\TestCase;
|
||||
use api\validators\EmailActivationKeyValidator;
|
||||
use Codeception\Specify;
|
||||
use common\helpers\Error as E;
|
||||
use common\models\confirmations\ForgotPassword;
|
||||
use common\models\EmailActivation;
|
||||
@@ -12,7 +11,6 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
use yii\base\Model;
|
||||
|
||||
class EmailActivationKeyValidatorTest extends TestCase {
|
||||
use Specify;
|
||||
use ProtectedCaller;
|
||||
|
||||
public function testValidateAttribute() {
|
||||
@@ -21,7 +19,7 @@ class EmailActivationKeyValidatorTest extends TestCase {
|
||||
public $key;
|
||||
};
|
||||
|
||||
/** @var EmailActivationKeyValidator|\PHPUnit_Framework_MockObject_MockObject $validator */
|
||||
/** @var EmailActivationKeyValidator|\PHPUnit\Framework\MockObject\MockObject $validator */
|
||||
$validator = $this->getMockBuilder(EmailActivationKeyValidator::class)
|
||||
->setMethods(['findEmailActivationModel'])
|
||||
->getMock();
|
||||
|
Reference in New Issue
Block a user