mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Update ely/php-code-style and run updated CS fixer
This commit is contained in:
@@ -14,7 +14,7 @@ class ValidatorTest extends TestCase {
|
||||
public function testValidateEmptyValue() {
|
||||
$validator = new Validator(mock(ClientInterface::class));
|
||||
$this->assertFalse($validator->validate('', $error));
|
||||
$this->assertEquals('error.captcha_required', $error, 'Get error.captcha_required, if passed empty value');
|
||||
$this->assertSame('error.captcha_required', $error, 'Get error.captcha_required, if passed empty value');
|
||||
}
|
||||
|
||||
public function testValidateInvalidValue() {
|
||||
@@ -28,7 +28,7 @@ class ValidatorTest extends TestCase {
|
||||
|
||||
$validator = new Validator($mockClient);
|
||||
$this->assertFalse($validator->validate('12341234', $error));
|
||||
$this->assertEquals('error.captcha_invalid', $error, 'Get error.captcha_invalid, if passed wrong value');
|
||||
$this->assertSame('error.captcha_invalid', $error, 'Get error.captcha_invalid, if passed wrong value');
|
||||
}
|
||||
|
||||
public function testValidateWithNetworkTroubles() {
|
||||
|
||||
@@ -45,17 +45,17 @@ class ComponentTest extends TestCase {
|
||||
$result = $this->component->createJwtAuthenticationToken($account, false);
|
||||
$this->assertInstanceOf(AuthenticationResult::class, $result);
|
||||
$this->assertNull($result->getSession());
|
||||
$this->assertEquals($account, $result->getAccount());
|
||||
$this->assertSame($account, $result->getAccount());
|
||||
$payloads = (new Jwt())->deserialize($result->getJwt())->getPayload();
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), 3);
|
||||
/** @noinspection SummerTimeUnsafeTimeManipulationInspection */
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time() + 60 * 60 * 24 * 7, $payloads->findClaimByName('exp')->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time() + 60 * 60 * 24 * 7, $payloads->findClaimByName('exp')->getValue(), 3);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
$this->assertSame('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
$this->assertSame('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
$this->assertNull($payloads->findClaimByName('jti'));
|
||||
|
||||
/** @var Account $account */
|
||||
@@ -63,20 +63,20 @@ class ComponentTest extends TestCase {
|
||||
$result = $this->component->createJwtAuthenticationToken($account, true);
|
||||
$this->assertInstanceOf(AuthenticationResult::class, $result);
|
||||
$this->assertInstanceOf(AccountSession::class, $result->getSession());
|
||||
$this->assertEquals($account, $result->getAccount());
|
||||
$this->assertSame($account, $result->getAccount());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertTrue($result->getSession()->refresh());
|
||||
$payloads = (new Jwt())->deserialize($result->getJwt())->getPayload();
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), 3);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time() + 3600, $payloads->findClaimByName('exp')->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time() + 3600, $payloads->findClaimByName('exp')->getValue(), 3);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
$this->assertSame('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
$this->assertSame('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals($result->getSession()->id, $payloads->findClaimByName('jti')->getValue());
|
||||
$this->assertSame($result->getSession()->id, $payloads->findClaimByName('jti')->getValue());
|
||||
}
|
||||
|
||||
public function testRenewJwtAuthenticationToken() {
|
||||
@@ -85,23 +85,22 @@ class ComponentTest extends TestCase {
|
||||
/** @var AccountSession $session */
|
||||
$session = $this->tester->grabFixture('sessions', 'admin');
|
||||
$result = $this->component->renewJwtAuthenticationToken($session);
|
||||
$this->assertInstanceOf(AuthenticationResult::class, $result);
|
||||
$this->assertEquals($session, $result->getSession());
|
||||
$this->assertEquals($session->account_id, $result->getAccount()->id);
|
||||
$this->assertSame($session, $result->getSession());
|
||||
$this->assertSame($session->account_id, $result->getAccount()->id);
|
||||
$session->refresh(); // reload data from db
|
||||
$this->assertEquals(time(), $session->last_refreshed_at, '', 3);
|
||||
$this->assertEquals($userIP, $session->getReadableIp());
|
||||
$this->assertEqualsWithDelta(time(), $session->last_refreshed_at, 3);
|
||||
$this->assertSame($userIP, $session->getReadableIp());
|
||||
$payloads = (new Jwt())->deserialize($result->getJwt())->getPayload();
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time(), $payloads->findClaimByName(Claim\IssuedAt::NAME)->getValue(), 3);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals(time() + 3600, $payloads->findClaimByName('exp')->getValue(), '', 3);
|
||||
$this->assertEqualsWithDelta(time() + 3600, $payloads->findClaimByName('exp')->getValue(), 3);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
$this->assertSame('ely|1', $payloads->findClaimByName('sub')->getValue());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
$this->assertSame('accounts_web_user', $payloads->findClaimByName('ely-scopes')->getValue());
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals($session->id, $payloads->findClaimByName('jti')->getValue(), 'session has not changed');
|
||||
$this->assertSame($session->id, $payloads->findClaimByName('jti')->getValue(), 'session has not changed');
|
||||
}
|
||||
|
||||
public function testParseToken() {
|
||||
@@ -123,7 +122,6 @@ class ComponentTest extends TestCase {
|
||||
->getMock();
|
||||
|
||||
$component
|
||||
->expects($this->any())
|
||||
->method('getIsGuest')
|
||||
->willReturn(false);
|
||||
|
||||
@@ -132,7 +130,7 @@ class ComponentTest extends TestCase {
|
||||
$session = $component->getActiveSession();
|
||||
$this->assertInstanceOf(AccountSession::class, $session);
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
$this->assertEquals($session->id, $result->getSession()->id);
|
||||
$this->assertSame($session->id, $result->getSession()->id);
|
||||
}
|
||||
|
||||
public function testTerminateSessions() {
|
||||
@@ -157,8 +155,8 @@ class ComponentTest extends TestCase {
|
||||
|
||||
$component->terminateSessions($account, Component::KEEP_CURRENT_SESSION);
|
||||
$sessions = $account->getSessions()->all();
|
||||
$this->assertEquals(1, count($sessions));
|
||||
$this->assertTrue($sessions[0]->id === $session->id);
|
||||
$this->assertCount(1, $sessions);
|
||||
$this->assertSame($session->id, $sessions[0]->id);
|
||||
|
||||
$component->terminateSessions($account);
|
||||
$this->assertEmpty($account->getSessions()->all());
|
||||
|
||||
@@ -17,12 +17,12 @@ class JwtAuthenticationResultTest extends TestCase {
|
||||
$account = new Account();
|
||||
$account->id = 123;
|
||||
$model = new AuthenticationResult($account, '', null);
|
||||
$this->assertEquals($account, $model->getAccount());
|
||||
$this->assertSame($account, $model->getAccount());
|
||||
}
|
||||
|
||||
public function testGetJwt() {
|
||||
$model = new AuthenticationResult(new Account(), 'mocked jwt', null);
|
||||
$this->assertEquals('mocked jwt', $model->getJwt());
|
||||
$this->assertSame('mocked jwt', $model->getJwt());
|
||||
}
|
||||
|
||||
public function testGetSession() {
|
||||
@@ -32,14 +32,14 @@ class JwtAuthenticationResultTest extends TestCase {
|
||||
$session = new AccountSession();
|
||||
$session->id = 321;
|
||||
$model = new AuthenticationResult(new Account(), '', $session);
|
||||
$this->assertEquals($session, $model->getSession());
|
||||
$this->assertSame($session, $model->getSession());
|
||||
}
|
||||
|
||||
public function testGetAsResponse() {
|
||||
$jwtToken = $this->createJwtToken(time() + 3600);
|
||||
$model = new AuthenticationResult(new Account(), $jwtToken, null);
|
||||
$result = $model->getAsResponse();
|
||||
$this->assertEquals($jwtToken, $result['access_token']);
|
||||
$this->assertSame($jwtToken, $result['access_token']);
|
||||
$this->assertSame(3600, $result['expires_in']);
|
||||
|
||||
/** @noinspection SummerTimeUnsafeTimeManipulationInspection */
|
||||
@@ -48,8 +48,8 @@ class JwtAuthenticationResultTest extends TestCase {
|
||||
$session->refresh_token = 'refresh token';
|
||||
$model = new AuthenticationResult(new Account(), $jwtToken, $session);
|
||||
$result = $model->getAsResponse();
|
||||
$this->assertEquals($jwtToken, $result['access_token']);
|
||||
$this->assertEquals('refresh token', $result['refresh_token']);
|
||||
$this->assertSame($jwtToken, $result['access_token']);
|
||||
$this->assertSame('refresh token', $result['refresh_token']);
|
||||
$this->assertSame(86400, $result['expires_in']);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class JwtIdentityTest extends TestCase {
|
||||
$token = $this->generateToken();
|
||||
$identity = JwtIdentity::findIdentityByAccessToken($token);
|
||||
$this->assertInstanceOf(IdentityInterface::class, $identity);
|
||||
$this->assertEquals($token, $identity->getId());
|
||||
$this->assertEquals($this->tester->grabFixture('accounts', 'admin')['id'], $identity->getAccount()->id);
|
||||
$this->assertSame($token, $identity->getId());
|
||||
$this->assertSame($this->tester->grabFixture('accounts', 'admin')['id'], $identity->getAccount()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ class ConfirmEmailFormTest extends TestCase {
|
||||
$this->assertFalse($activationExists, 'email activation key is not exist');
|
||||
/** @var Account $account */
|
||||
$account = Account::findOne($fixture['account_id']);
|
||||
$this->assertEquals(Account::STATUS_ACTIVE, $account->status, 'user status changed to active');
|
||||
$this->assertSame(Account::STATUS_ACTIVE, $account->status, 'user status changed to active');
|
||||
}
|
||||
|
||||
private function createModel($key) {
|
||||
|
||||
@@ -16,7 +16,7 @@ use Yii;
|
||||
class ForgotPasswordFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
Yii::$container->set(ReCaptchaValidator::class, new class(mock(ClientInterface::class)) extends ReCaptchaValidator {
|
||||
public function validateValue($value) {
|
||||
@@ -35,7 +35,7 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
public function testValidateLogin() {
|
||||
$model = new ForgotPasswordForm(['login' => 'unexist']);
|
||||
$model->validateLogin('login');
|
||||
$this->assertEquals(['error.login_not_exist'], $model->getErrors('login'), 'error.login_not_exist if login is invalid');
|
||||
$this->assertSame(['error.login_not_exist'], $model->getErrors('login'), 'error.login_not_exist if login is invalid');
|
||||
|
||||
$model = new ForgotPasswordForm(['login' => $this->tester->grabFixture('accounts', 'admin')['username']]);
|
||||
$model->validateLogin('login');
|
||||
@@ -47,7 +47,7 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
'login' => $this->tester->grabFixture('accounts', 'not-activated-account')['username'],
|
||||
]);
|
||||
$model->validateActivity('login');
|
||||
$this->assertEquals(['error.account_not_activated'], $model->getErrors('login'), 'expected error if account is not confirmed');
|
||||
$this->assertSame(['error.account_not_activated'], $model->getErrors('login'), 'expected error if account is not confirmed');
|
||||
|
||||
$model = new ForgotPasswordForm([
|
||||
'login' => $this->tester->grabFixture('accounts', 'admin')['username'],
|
||||
@@ -62,7 +62,7 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
'key' => $this->tester->grabFixture('emailActivations', 'freshPasswordRecovery')['key'],
|
||||
]);
|
||||
$model->validateFrequency('login');
|
||||
$this->assertEquals(['error.recently_sent_message'], $model->getErrors('login'), 'error.account_not_activated if recently was message');
|
||||
$this->assertSame(['error.recently_sent_message'], $model->getErrors('login'), 'error.account_not_activated if recently was message');
|
||||
|
||||
$model = $this->createModel([
|
||||
'login' => $this->tester->grabFixture('accounts', 'admin')['username'],
|
||||
|
||||
@@ -14,13 +14,13 @@ class LoginFormTest extends TestCase {
|
||||
|
||||
private $originalRemoteAddr;
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
$this->originalRemoteAddr = $_SERVER['REMOTE_ADDR'] ?? null;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
$_SERVER['REMOTE_ADDR'] = $this->originalRemoteAddr;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class LoginFormTest extends TestCase {
|
||||
'account' => null,
|
||||
]);
|
||||
$model->validateLogin('login');
|
||||
$this->assertEquals(['error.login_not_exist'], $model->getErrors('login'));
|
||||
$this->assertSame(['error.login_not_exist'], $model->getErrors('login'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if login exists', function() {
|
||||
@@ -58,7 +58,7 @@ class LoginFormTest extends TestCase {
|
||||
'account' => new Account(['password' => '12345678']),
|
||||
]);
|
||||
$model->validatePassword('password');
|
||||
$this->assertEquals(['error.password_incorrect'], $model->getErrors('password'));
|
||||
$this->assertSame(['error.password_incorrect'], $model->getErrors('password'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if password valid', function() {
|
||||
@@ -84,7 +84,7 @@ class LoginFormTest extends TestCase {
|
||||
'account' => $account,
|
||||
]);
|
||||
$model->validateTotp('totp');
|
||||
$this->assertEquals(['error.totp_incorrect'], $model->getErrors('totp'));
|
||||
$this->assertSame(['error.totp_incorrect'], $model->getErrors('totp'));
|
||||
});
|
||||
|
||||
$totp = TOTP::create($account->otp_secret);
|
||||
@@ -105,7 +105,7 @@ class LoginFormTest extends TestCase {
|
||||
'account' => new Account(['status' => Account::STATUS_REGISTERED]),
|
||||
]);
|
||||
$model->validateActivity('login');
|
||||
$this->assertEquals(['error.account_not_activated'], $model->getErrors('login'));
|
||||
$this->assertSame(['error.account_not_activated'], $model->getErrors('login'));
|
||||
});
|
||||
|
||||
$this->specify('error.account_banned if account has banned status', function() {
|
||||
@@ -113,7 +113,7 @@ class LoginFormTest extends TestCase {
|
||||
'account' => new Account(['status' => Account::STATUS_BANNED]),
|
||||
]);
|
||||
$model->validateActivity('login');
|
||||
$this->assertEquals(['error.account_banned'], $model->getErrors('login'));
|
||||
$this->assertSame(['error.account_banned'], $model->getErrors('login'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if account active', function() {
|
||||
@@ -146,7 +146,7 @@ class LoginFormTest extends TestCase {
|
||||
]);
|
||||
$this->assertInstanceOf(AuthenticationResult::class, $model->login());
|
||||
$this->assertEmpty($model->getErrors());
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
Account::PASS_HASH_STRATEGY_YII2,
|
||||
$model->getAccount()->password_hash_strategy,
|
||||
'user, that login using account with old pass hash strategy should update it automatically'
|
||||
|
||||
@@ -26,7 +26,7 @@ class RefreshTokenFormTest extends TestCase {
|
||||
}
|
||||
};
|
||||
$model->validateRefreshToken();
|
||||
$this->assertEquals(['error.refresh_token_not_exist'], $model->getErrors('refresh_token'));
|
||||
$this->assertSame(['error.refresh_token_not_exist'], $model->getErrors('refresh_token'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if token exists', function() {
|
||||
|
||||
@@ -20,7 +20,7 @@ use const common\LATEST_RULES_VERSION;
|
||||
|
||||
class RegistrationFormTest extends TestCase {
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->mockRequest();
|
||||
Yii::$container->set(ReCaptchaValidator::class, new class(mock(ClientInterface::class)) extends ReCaptchaValidator {
|
||||
@@ -68,7 +68,7 @@ class RegistrationFormTest extends TestCase {
|
||||
$account = $model->signup();
|
||||
|
||||
$this->expectSuccessRegistration($account);
|
||||
$this->assertEquals('ru', $account->lang, 'lang is set');
|
||||
$this->assertSame('ru', $account->lang, 'lang is set');
|
||||
}
|
||||
|
||||
public function testSignupWithDefaultLanguage() {
|
||||
@@ -84,7 +84,7 @@ class RegistrationFormTest extends TestCase {
|
||||
$account = $model->signup();
|
||||
|
||||
$this->expectSuccessRegistration($account);
|
||||
$this->assertEquals('en', $account->lang, 'lang is set');
|
||||
$this->assertSame('en', $account->lang, 'lang is set');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ class RegistrationFormTest extends TestCase {
|
||||
$this->assertTrue($account->validatePassword('some_password'), 'password should be correct');
|
||||
$this->assertNotEmpty($account->uuid, 'uuid is set');
|
||||
$this->assertNotNull($account->registration_ip, 'registration_ip is set');
|
||||
$this->assertEquals(LATEST_RULES_VERSION, $account->rules_agreement_version, 'actual rules version is set');
|
||||
$this->assertSame(LATEST_RULES_VERSION, $account->rules_agreement_version, 'actual rules version is set');
|
||||
$this->assertTrue(Account::find()->andWhere([
|
||||
'username' => 'some_username',
|
||||
'email' => 'some_email@example.com',
|
||||
|
||||
@@ -15,7 +15,7 @@ use Yii;
|
||||
class RepeatAccountActivationFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
Yii::$container->set(ReCaptchaValidator::class, new class(mock(ClientInterface::class)) extends ReCaptchaValidator {
|
||||
public function validateValue($value) {
|
||||
|
||||
@@ -9,7 +9,7 @@ class ApiFormTest extends TestCase {
|
||||
public function testLoad() {
|
||||
$model = new DummyApiForm();
|
||||
$this->assertTrue($model->load(['field' => 'test-data']), 'model successful load data without prefix');
|
||||
$this->assertEquals('test-data', $model->field, 'field is set as passed data');
|
||||
$this->assertSame('test-data', $model->field, 'field is set as passed data');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class AcceptRulesFormTest extends TestCase {
|
||||
|
||||
$model = new AcceptRulesForm($account);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals(LATEST_RULES_VERSION, $account->rules_agreement_version);
|
||||
$this->assertSame(LATEST_RULES_VERSION, $account->rules_agreement_version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class ChangeEmailFormTest extends TestCase {
|
||||
]));
|
||||
/** @noinspection UnserializeExploitsInspection */
|
||||
$data = unserialize($newEmailConfirmationFixture['_data']);
|
||||
$this->assertEquals($data['newEmail'], $account->email);
|
||||
$this->assertSame($data['newEmail'], $account->email);
|
||||
}
|
||||
|
||||
private function getAccountId() {
|
||||
|
||||
@@ -15,7 +15,7 @@ class ChangeLanguageFormTest extends TestCase {
|
||||
$model = new ChangeLanguageForm($account);
|
||||
$model->lang = 'ru';
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals('ru', $account->lang);
|
||||
$this->assertSame('ru', $account->lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ChangePasswordFormTest extends TestCase {
|
||||
'newRePassword' => 'another-password',
|
||||
]);
|
||||
$model->validatePasswordAndRePasswordMatch('newRePassword');
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
[E::NEW_RE_PASSWORD_DOES_NOT_MATCH],
|
||||
$model->getErrors('newRePassword'),
|
||||
'error.rePassword_does_not_match expected if passwords not match'
|
||||
@@ -47,7 +47,7 @@ class ChangePasswordFormTest extends TestCase {
|
||||
'newRePassword' => 'another-password',
|
||||
]);
|
||||
$model->validate();
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
[E::NEW_RE_PASSWORD_DOES_NOT_MATCH],
|
||||
$model->getErrors('newRePassword'),
|
||||
'error.rePassword_does_not_match expected even if there are errors on other attributes'
|
||||
@@ -106,7 +106,7 @@ class ChangePasswordFormTest extends TestCase {
|
||||
$this->assertTrue($model->performAction(), 'successfully change password with legacy hash strategy');
|
||||
$this->assertTrue($account->validatePassword('my-new-password'));
|
||||
$this->assertGreaterThanOrEqual($callTime, $account->password_changed_at);
|
||||
$this->assertEquals(Account::PASS_HASH_STRATEGY_YII2, $account->password_hash_strategy);
|
||||
$this->assertSame(Account::PASS_HASH_STRATEGY_YII2, $account->password_hash_strategy);
|
||||
}
|
||||
|
||||
public function testPerformActionWithLogout() {
|
||||
|
||||
@@ -24,7 +24,7 @@ class ChangeUsernameFormTest extends TestCase {
|
||||
'username' => 'my_new_nickname',
|
||||
]);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals('my_new_nickname', Account::findOne($this->getAccountId())->username);
|
||||
$this->assertSame('my_new_nickname', Account::findOne($this->getAccountId())->username);
|
||||
$this->assertInstanceOf(UsernameHistory::class, UsernameHistory::findOne(['username' => 'my_new_nickname']));
|
||||
/** @var PullMojangUsername $job */
|
||||
$job = $this->tester->grabLastQueuedJob();
|
||||
@@ -56,7 +56,7 @@ class ChangeUsernameFormTest extends TestCase {
|
||||
'username' => $newUsername,
|
||||
]);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals($newUsername, Account::findOne($this->getAccountId())->username);
|
||||
$this->assertSame($newUsername, Account::findOne($this->getAccountId())->username);
|
||||
$this->assertInstanceOf(
|
||||
UsernameHistory::class,
|
||||
UsernameHistory::findOne(['username' => $newUsername]),
|
||||
|
||||
@@ -30,7 +30,7 @@ class DisableTwoFactorAuthFormTest extends TestCase {
|
||||
$account->is_otp_enabled = false;
|
||||
$model = new DisableTwoFactorAuthForm($account);
|
||||
$model->validateOtpEnabled('account');
|
||||
$this->assertEquals([E::OTP_NOT_ENABLED], $model->getErrors('account'));
|
||||
$this->assertSame([E::OTP_NOT_ENABLED], $model->getErrors('account'));
|
||||
|
||||
$account = new Account();
|
||||
$account->is_otp_enabled = true;
|
||||
|
||||
@@ -42,7 +42,7 @@ class EnableTwoFactorAuthFormTest extends TestCase {
|
||||
$account->is_otp_enabled = true;
|
||||
$model = new EnableTwoFactorAuthForm($account);
|
||||
$model->validateOtpDisabled('account');
|
||||
$this->assertEquals([E::OTP_ALREADY_ENABLED], $model->getErrors('account'));
|
||||
$this->assertSame([E::OTP_ALREADY_ENABLED], $model->getErrors('account'));
|
||||
|
||||
$account = new Account();
|
||||
$account->is_otp_enabled = false;
|
||||
|
||||
@@ -25,7 +25,7 @@ class SendEmailVerificationFormTest extends TestCase {
|
||||
$model = new SendEmailVerificationForm($account);
|
||||
$activationModel = $model->createCode();
|
||||
$this->assertInstanceOf(CurrentEmailConfirmation::class, $activationModel);
|
||||
$this->assertEquals($account->id, $activationModel->account_id);
|
||||
$this->assertSame($account->id, $activationModel->account_id);
|
||||
$this->assertNotNull(EmailActivation::findOne($activationModel->key));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class SendNewEmailVerificationFormTest extends TestCase {
|
||||
$model->email = 'my-new-email@ely.by';
|
||||
$activationModel = $model->createCode();
|
||||
$this->assertInstanceOf(NewEmailConfirmation::class, $activationModel);
|
||||
$this->assertEquals($account->id, $activationModel->account_id);
|
||||
$this->assertEquals($model->email, $activationModel->newEmail);
|
||||
$this->assertSame($account->id, $activationModel->account_id);
|
||||
$this->assertSame($model->email, $activationModel->newEmail);
|
||||
$this->assertNotNull(EmailActivation::findOne($activationModel->key));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class TwoFactorAuthInfoTest extends TestCase {
|
||||
$model = new TwoFactorAuthInfo($account);
|
||||
|
||||
$result = $model->getCredentials();
|
||||
$this->assertEquals('AAAA', $result['secret']);
|
||||
$this->assertSame('AAAA', $result['secret']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class AuthenticationFormTest extends TestCase {
|
||||
|
||||
$result = $authForm->authenticate();
|
||||
$this->assertInstanceOf(AuthenticateData::class, $result);
|
||||
$this->assertEquals($minecraftAccessKey->access_token, $result->getMinecraftAccessKey()->access_token);
|
||||
$this->assertSame($minecraftAccessKey->access_token, $result->getMinecraftAccessKey()->access_token);
|
||||
}
|
||||
|
||||
public function testCreateMinecraftAccessToken() {
|
||||
@@ -90,8 +90,8 @@ class AuthenticationFormTest extends TestCase {
|
||||
/** @var MinecraftAccessKey $result */
|
||||
$result = $this->callProtected($authForm, 'createMinecraftAccessToken', $account);
|
||||
$this->assertInstanceOf(MinecraftAccessKey::class, $result);
|
||||
$this->assertEquals($account->id, $result->account_id);
|
||||
$this->assertEquals($authForm->clientToken, $result->client_token);
|
||||
$this->assertSame($account->id, $result->account_id);
|
||||
$this->assertSame($authForm->clientToken, $result->client_token);
|
||||
$this->assertInstanceOf(MinecraftAccessKey::class, MinecraftAccessKey::findOne($result->access_token));
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ class AuthenticationFormTest extends TestCase {
|
||||
/** @var MinecraftAccessKey $result */
|
||||
$result = $this->callProtected($authForm, 'createMinecraftAccessToken', $account);
|
||||
$this->assertInstanceOf(MinecraftAccessKey::class, $result);
|
||||
$this->assertEquals($account->id, $result->account_id);
|
||||
$this->assertEquals($authForm->clientToken, $result->client_token);
|
||||
$this->assertSame($account->id, $result->account_id);
|
||||
$this->assertSame($authForm->clientToken, $result->client_token);
|
||||
$this->assertNull(MinecraftAccessKey::findOne($minecraftFixture['access_token']));
|
||||
$this->assertInstanceOf(MinecraftAccessKey::class, MinecraftAccessKey::findOne($result->access_token));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class BanFormTest extends TestCase {
|
||||
$account->status = Account::STATUS_BANNED;
|
||||
$form = new BanAccountForm($account);
|
||||
$form->validateAccountActivity();
|
||||
$this->assertEquals([E::ACCOUNT_ALREADY_BANNED], $form->getErrors('account'));
|
||||
$this->assertSame([E::ACCOUNT_ALREADY_BANNED], $form->getErrors('account'));
|
||||
}
|
||||
|
||||
public function testBan() {
|
||||
@@ -35,7 +35,7 @@ class BanFormTest extends TestCase {
|
||||
|
||||
$model = new BanAccountForm($account);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals(Account::STATUS_BANNED, $account->status);
|
||||
$this->assertSame(Account::STATUS_BANNED, $account->status);
|
||||
/** @var ClearAccountSessions $job */
|
||||
$job = $this->tester->grabLastQueuedJob();
|
||||
$this->assertInstanceOf(ClearAccountSessions::class, $job);
|
||||
|
||||
@@ -19,7 +19,7 @@ class PardonFormTest extends TestCase {
|
||||
$account->status = Account::STATUS_ACTIVE;
|
||||
$form = new PardonAccountForm($account);
|
||||
$form->validateAccountBanned();
|
||||
$this->assertEquals([E::ACCOUNT_NOT_BANNED], $form->getErrors('account'));
|
||||
$this->assertSame([E::ACCOUNT_NOT_BANNED], $form->getErrors('account'));
|
||||
}
|
||||
|
||||
public function testPardon() {
|
||||
@@ -35,7 +35,7 @@ class PardonFormTest extends TestCase {
|
||||
$account->status = Account::STATUS_BANNED;
|
||||
$model = new PardonAccountForm($account);
|
||||
$this->assertTrue($model->performAction());
|
||||
$this->assertEquals(Account::STATUS_ACTIVE, $account->status);
|
||||
$this->assertSame(Account::STATUS_ACTIVE, $account->status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class OauthClientFormTest extends TestCase {
|
||||
$job = $this->tester->grabLastQueuedJob();
|
||||
$this->assertInstanceOf(ClearOauthSessions::class, $job);
|
||||
$this->assertSame('mocked-id', $job->clientId);
|
||||
$this->assertEquals(time(), $job->notSince, '', 2);
|
||||
$this->assertEqualsWithDelta(time(), $job->notSince, 2);
|
||||
}
|
||||
|
||||
public function testResetWithSecret() {
|
||||
@@ -132,7 +132,7 @@ class OauthClientFormTest extends TestCase {
|
||||
$job = $this->tester->grabLastQueuedJob();
|
||||
$this->assertInstanceOf(ClearOauthSessions::class, $job);
|
||||
$this->assertSame('mocked-id', $job->clientId);
|
||||
$this->assertEquals(time(), $job->notSince, '', 2);
|
||||
$this->assertEqualsWithDelta(time(), $job->notSince, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ class RequestParserTest extends TestCase {
|
||||
public function testParse() {
|
||||
$parser = new RequestParser();
|
||||
$_POST = ['from' => 'post'];
|
||||
$this->assertEquals(['from' => 'post'], $parser->parse('from=post', ''));
|
||||
$this->assertEquals(['from' => 'post'], $parser->parse('', ''));
|
||||
$this->assertSame(['from' => 'post'], $parser->parse('from=post', ''));
|
||||
$this->assertSame(['from' => 'post'], $parser->parse('', ''));
|
||||
$_POST = [];
|
||||
$this->assertEquals(['from' => 'json'], $parser->parse('{"from":"json"}', ''));
|
||||
$this->assertEquals(['from' => 'body'], $parser->parse('from=body', ''));
|
||||
$this->assertEquals(['onlykey' => ''], $parser->parse('onlykey', ''));
|
||||
$this->assertSame(['from' => 'json'], $parser->parse('{"from":"json"}', ''));
|
||||
$this->assertSame(['from' => 'body'], $parser->parse('from=body', ''));
|
||||
$this->assertSame(['onlykey' => ''], $parser->parse('onlykey', ''));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ class AccountFinderTest extends TestCase {
|
||||
public function testGetLoginAttribute() {
|
||||
$model = new AccountFinderTestTestClass();
|
||||
$model->login = 'erickskrauch@ely.by';
|
||||
$this->assertEquals('email', $model->getLoginAttribute(), 'if login look like email value, then \'email\'');
|
||||
$this->assertSame('email', $model->getLoginAttribute(), 'if login look like email value, then \'email\'');
|
||||
|
||||
$model = new AccountFinderTestTestClass();
|
||||
$model->login = 'erickskrauch';
|
||||
$this->assertEquals('username', $model->getLoginAttribute(), 'username in any other case');
|
||||
$this->assertSame('username', $model->getLoginAttribute(), 'username in any other case');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,24 +36,24 @@ class EmailActivationKeyValidatorTest extends TestCase {
|
||||
->willReturnOnConsecutiveCalls(null, $expiredActivation, $validActivation);
|
||||
|
||||
$validator->validateAttribute($model, 'key');
|
||||
$this->assertEquals([E::KEY_REQUIRED], $model->getErrors('key'));
|
||||
$this->assertSame([E::KEY_REQUIRED], $model->getErrors('key'));
|
||||
$this->assertNull($model->key);
|
||||
|
||||
$model->clearErrors();
|
||||
$model->key = 'original value';
|
||||
$validator->validateAttribute($model, 'key');
|
||||
$this->assertEquals([E::KEY_NOT_EXISTS], $model->getErrors('key'));
|
||||
$this->assertEquals('original value', $model->key);
|
||||
$this->assertSame([E::KEY_NOT_EXISTS], $model->getErrors('key'));
|
||||
$this->assertSame('original value', $model->key);
|
||||
|
||||
$model->clearErrors();
|
||||
$validator->validateAttribute($model, 'key');
|
||||
$this->assertEquals([E::KEY_EXPIRE], $model->getErrors('key'));
|
||||
$this->assertEquals('original value', $model->key);
|
||||
$this->assertSame([E::KEY_EXPIRE], $model->getErrors('key'));
|
||||
$this->assertSame('original value', $model->key);
|
||||
|
||||
$model->clearErrors();
|
||||
$validator->validateAttribute($model, 'key');
|
||||
$this->assertEmpty($model->getErrors('key'));
|
||||
$this->assertEquals($validActivation, $model->key);
|
||||
$this->assertSame($validActivation, $model->key);
|
||||
}
|
||||
|
||||
public function testFindEmailActivationModel() {
|
||||
@@ -64,7 +64,7 @@ class EmailActivationKeyValidatorTest extends TestCase {
|
||||
/** @var EmailActivation $result */
|
||||
$result = $this->callProtected($model, 'findEmailActivationModel', $key);
|
||||
$this->assertInstanceOf(EmailActivation::class, $result, 'valid key without specifying type must return model');
|
||||
$this->assertEquals($key, $result->key);
|
||||
$this->assertSame($key, $result->key);
|
||||
|
||||
/** @var EmailActivation $result */
|
||||
$result = $this->callProtected($model, 'findEmailActivationModel', $key, 0);
|
||||
|
||||
@@ -17,10 +17,10 @@ class PasswordRequiredValidatorTest extends TestCase {
|
||||
$model = new PasswordRequiredValidator(['account' => $account]);
|
||||
|
||||
// Get error.password_required if password is empty
|
||||
$this->assertEquals([E::PASSWORD_REQUIRED, []], $this->callProtected($model, 'validateValue', ''));
|
||||
$this->assertSame([E::PASSWORD_REQUIRED, []], $this->callProtected($model, 'validateValue', ''));
|
||||
|
||||
// Get error.password_incorrect if password is incorrect
|
||||
$this->assertEquals([E::PASSWORD_INCORRECT, []], $this->callProtected($model, 'validateValue', '87654321'));
|
||||
$this->assertSame([E::PASSWORD_INCORRECT, []], $this->callProtected($model, 'validateValue', '87654321'));
|
||||
|
||||
// No errors, if password is correct for provided account
|
||||
$this->assertNull($this->callProtected($model, 'validateValue', '12345678'));
|
||||
|
||||
@@ -19,13 +19,13 @@ class TotpValidatorTest extends TestCase {
|
||||
$validator = new TotpValidator(['account' => $account]);
|
||||
|
||||
$result = $this->callProtected($validator, 'validateValue', 123456);
|
||||
$this->assertEquals([E::TOTP_INCORRECT, []], $result);
|
||||
$this->assertSame([E::TOTP_INCORRECT, []], $result);
|
||||
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->now());
|
||||
$this->assertNull($result);
|
||||
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31));
|
||||
$this->assertEquals([E::TOTP_INCORRECT, []], $result);
|
||||
$this->assertSame([E::TOTP_INCORRECT, []], $result);
|
||||
|
||||
$validator->window = 2;
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31));
|
||||
@@ -34,7 +34,7 @@ class TotpValidatorTest extends TestCase {
|
||||
$at = time() - 400;
|
||||
$validator->timestamp = $at;
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->now());
|
||||
$this->assertEquals([E::TOTP_INCORRECT, []], $result);
|
||||
$this->assertSame([E::TOTP_INCORRECT, []], $result);
|
||||
|
||||
$result = $this->callProtected($validator, 'validateValue', $controlTotp->at($at));
|
||||
$this->assertNull($result);
|
||||
|
||||
Reference in New Issue
Block a user