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:
@@ -17,7 +17,7 @@ class DataBehaviorTest extends TestCase {
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
$this->callProtected($behavior, 'setKey', 'my-key', 'my-value');
|
||||
$this->assertEquals(serialize(['my-key' => 'my-value']), $model->_data);
|
||||
$this->assertSame(serialize(['my-key' => 'my-value']), $model->_data);
|
||||
}
|
||||
|
||||
public function testGetKey() {
|
||||
@@ -25,7 +25,7 @@ class DataBehaviorTest extends TestCase {
|
||||
$model->_data = serialize(['some-key' => 'some-value']);
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
$this->assertEquals('some-value', $this->callProtected($behavior, 'getKey', 'some-key'));
|
||||
$this->assertSame('some-value', $this->callProtected($behavior, 'getKey', 'some-key'));
|
||||
}
|
||||
|
||||
public function testGetData() {
|
||||
|
@@ -15,7 +15,7 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
$behavior = $this->createBehavior();
|
||||
$time = time();
|
||||
$behavior->owner->created_at = $time;
|
||||
$this->assertEquals($time + 10, $this->callProtected($behavior, 'calculateTime', 10));
|
||||
$this->assertSame($time + 10, $this->callProtected($behavior, 'calculateTime', 10));
|
||||
}
|
||||
|
||||
public function testCompareTime() {
|
||||
|
@@ -31,8 +31,8 @@ class ApiTest extends TestCase {
|
||||
$this->handler->append(new Response(200, [], '{"id": "7125ba8b1c864508b92bb5c042ccfe2b","name": "KrisJelbring"}'));
|
||||
$response = (new Api())->usernameToUUID('KrisJelbring');
|
||||
$this->assertInstanceOf(UsernameToUUIDResponse::class, $response);
|
||||
$this->assertEquals('7125ba8b1c864508b92bb5c042ccfe2b', $response->id);
|
||||
$this->assertEquals('KrisJelbring', $response->name);
|
||||
$this->assertSame('7125ba8b1c864508b92bb5c042ccfe2b', $response->id);
|
||||
$this->assertSame('KrisJelbring', $response->name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,7 +10,7 @@ class QueryBuilderTest extends TestCase {
|
||||
public function testBuildOrderByField() {
|
||||
$queryBuilder = new QueryBuilder(Yii::$app->db);
|
||||
$result = $queryBuilder->buildOrderBy(['dummy' => ['first', 'second']]);
|
||||
$this->assertEquals("ORDER BY FIELD(`dummy`,'first','second')", $result);
|
||||
$this->assertSame("ORDER BY FIELD(`dummy`,'first','second')", $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ class TemplateTest extends TestCase {
|
||||
public function testConstructor() {
|
||||
/** @var Template|\Mockery\MockInterface $template */
|
||||
$template = mock(Template::class, ['find-me'])->makePartial();
|
||||
$this->assertEquals('find-me', $template->getTo());
|
||||
$this->assertSame('find-me', $template->getTo());
|
||||
$this->assertInstanceOf(MailerInterface::class, $template->getMailer());
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ class TemplateTest extends TestCase {
|
||||
Yii::$app->params['fromEmail'] = 'find-me';
|
||||
/** @var Template|\Mockery\MockInterface $template */
|
||||
$template = mock(Template::class)->makePartial();
|
||||
$this->assertEquals(['find-me' => 'Ely.by Accounts'], $template->getFrom());
|
||||
$this->assertSame(['find-me' => 'Ely.by Accounts'], $template->getFrom());
|
||||
}
|
||||
|
||||
public function testGetParams() {
|
||||
/** @var Template|\Mockery\MockInterface $template */
|
||||
$template = mock(Template::class)->makePartial();
|
||||
$this->assertEquals([], $template->getParams());
|
||||
$this->assertSame([], $template->getParams());
|
||||
}
|
||||
|
||||
public function testCreateMessage() {
|
||||
@@ -39,9 +39,9 @@ class TemplateTest extends TestCase {
|
||||
/** @var MessageInterface $message */
|
||||
$message = $this->callProtected($template, 'createMessage');
|
||||
$this->assertInstanceOf(MessageInterface::class, $message);
|
||||
$this->assertEquals(['to@ely.by' => 'To'], $message->getTo());
|
||||
$this->assertEquals(['from@ely.by' => 'Ely.by Accounts'], $message->getFrom());
|
||||
$this->assertEquals('mock-subject', $message->getSubject());
|
||||
$this->assertSame(['to@ely.by' => 'To'], $message->getTo());
|
||||
$this->assertSame(['from@ely.by' => 'Ely.by Accounts'], $message->getFrom());
|
||||
$this->assertSame('mock-subject', $message->getSubject());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,8 +15,8 @@ class TemplateWithRendererTest extends TestCase {
|
||||
public function testConstructor() {
|
||||
/** @var TemplateWithRenderer|\Mockery\MockInterface $template */
|
||||
$template = mock(TemplateWithRenderer::class, ['mock-to', 'mock-locale'])->makePartial();
|
||||
$this->assertEquals('mock-to', $template->getTo());
|
||||
$this->assertEquals('mock-locale', $template->getLocale());
|
||||
$this->assertSame('mock-to', $template->getTo());
|
||||
$this->assertSame('mock-locale', $template->getLocale());
|
||||
$this->assertInstanceOf(MailerInterface::class, $template->getMailer());
|
||||
$this->assertInstanceOf(EmailRenderer::class, $template->getEmailRenderer());
|
||||
}
|
||||
@@ -40,10 +40,10 @@ class TemplateWithRendererTest extends TestCase {
|
||||
/** @var \yii\swiftmailer\Message $message */
|
||||
$message = $this->callProtected($template, 'createMessage');
|
||||
$this->assertInstanceOf(MessageInterface::class, $message);
|
||||
$this->assertEquals(['to@ely.by' => 'To'], $message->getTo());
|
||||
$this->assertEquals(['from@ely.by' => 'From'], $message->getFrom());
|
||||
$this->assertEquals('mock-subject', $message->getSubject());
|
||||
$this->assertEquals('mock-html', $message->getSwiftMessage()->getBody());
|
||||
$this->assertSame(['to@ely.by' => 'To'], $message->getTo());
|
||||
$this->assertSame(['from@ely.by' => 'From'], $message->getFrom());
|
||||
$this->assertSame('mock-subject', $message->getSubject());
|
||||
$this->assertSame('mock-html', $message->getSwiftMessage()->getBody());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,11 +7,11 @@ use common\tests\unit\TestCase;
|
||||
class StringHelperTest extends TestCase {
|
||||
|
||||
public function testGetEmailMask() {
|
||||
$this->assertEquals('**@ely.by', StringHelper::getEmailMask('e@ely.by'));
|
||||
$this->assertEquals('e**@ely.by', StringHelper::getEmailMask('es@ely.by'));
|
||||
$this->assertEquals('e**i@ely.by', StringHelper::getEmailMask('eri@ely.by'));
|
||||
$this->assertEquals('er**ch@ely.by', StringHelper::getEmailMask('erickskrauch@ely.by'));
|
||||
$this->assertEquals('эр**уч@елу.бел', StringHelper::getEmailMask('эрикскрауч@елу.бел'));
|
||||
$this->assertSame('**@ely.by', StringHelper::getEmailMask('e@ely.by'));
|
||||
$this->assertSame('e**@ely.by', StringHelper::getEmailMask('es@ely.by'));
|
||||
$this->assertSame('e**i@ely.by', StringHelper::getEmailMask('eri@ely.by'));
|
||||
$this->assertSame('er**ch@ely.by', StringHelper::getEmailMask('erickskrauch@ely.by'));
|
||||
$this->assertSame('эр**уч@елу.бел', StringHelper::getEmailMask('эрикскрауч@елу.бел'));
|
||||
}
|
||||
|
||||
public function testIsUuid() {
|
||||
@@ -25,7 +25,7 @@ class StringHelperTest extends TestCase {
|
||||
*/
|
||||
public function testTrim($expected, $string) {
|
||||
$result = StringHelper::trim($string);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -15,13 +15,13 @@ class AccountSessionTest extends TestCase {
|
||||
public function testSetIp() {
|
||||
$model = new AccountSession();
|
||||
$model->setIp('127.0.0.1');
|
||||
$this->assertEquals(2130706433, $model->last_used_ip, 'method should convert passed ip string to long');
|
||||
$this->assertSame(2130706433, $model->last_used_ip, 'method should convert passed ip string to long');
|
||||
}
|
||||
|
||||
public function testGetReadableIp() {
|
||||
$model = new AccountSession();
|
||||
$model->last_used_ip = 2130706433;
|
||||
$this->assertEquals('127.0.0.1', $model->getReadableIp(), 'method should convert stored long into readable ip');
|
||||
$this->assertSame('127.0.0.1', $model->getReadableIp(), 'method should convert stored long into readable ip');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class AccountTest extends TestCase {
|
||||
$model->setPassword('12345678');
|
||||
$this->assertNotEmpty($model->password_hash, 'hash should be set');
|
||||
$this->assertTrue($model->validatePassword('12345678'), 'validation should be passed');
|
||||
$this->assertEquals(Account::PASS_HASH_STRATEGY_YII2, $model->password_hash_strategy, 'latest password hash should be used');
|
||||
$this->assertSame(Account::PASS_HASH_STRATEGY_YII2, $model->password_hash_strategy, 'latest password hash should be used');
|
||||
}
|
||||
|
||||
public function testValidatePassword() {
|
||||
@@ -83,7 +83,7 @@ class AccountTest extends TestCase {
|
||||
public function testGetProfileLink() {
|
||||
$model = new Account();
|
||||
$model->id = '123';
|
||||
$this->assertEquals('http://ely.by/u123', $model->getProfileLink());
|
||||
$this->assertSame('http://ely.by/u123', $model->getProfileLink());
|
||||
}
|
||||
|
||||
public function testIsAgreedWithActualRules() {
|
||||
@@ -108,9 +108,9 @@ class AccountTest extends TestCase {
|
||||
public function testSetRegistrationIp() {
|
||||
$account = new Account();
|
||||
$account->setRegistrationIp('42.72.205.204');
|
||||
$this->assertEquals('42.72.205.204', inet_ntop($account->registration_ip));
|
||||
$this->assertSame('42.72.205.204', inet_ntop($account->registration_ip));
|
||||
$account->setRegistrationIp('2001:1620:28:1:b6f:8bca:93:a116');
|
||||
$this->assertEquals('2001:1620:28:1:b6f:8bca:93:a116', inet_ntop($account->registration_ip));
|
||||
$this->assertSame('2001:1620:28:1:b6f:8bca:93:a116', inet_ntop($account->registration_ip));
|
||||
$account->setRegistrationIp(null);
|
||||
$this->assertNull($account->registration_ip);
|
||||
}
|
||||
@@ -118,9 +118,9 @@ class AccountTest extends TestCase {
|
||||
public function testGetRegistrationIp() {
|
||||
$account = new Account();
|
||||
$account->setRegistrationIp('42.72.205.204');
|
||||
$this->assertEquals('42.72.205.204', $account->getRegistrationIp());
|
||||
$this->assertSame('42.72.205.204', $account->getRegistrationIp());
|
||||
$account->setRegistrationIp('2001:1620:28:1:b6f:8bca:93:a116');
|
||||
$this->assertEquals('2001:1620:28:1:b6f:8bca:93:a116', $account->getRegistrationIp());
|
||||
$this->assertSame('2001:1620:28:1:b6f:8bca:93:a116', $account->getRegistrationIp());
|
||||
$account->setRegistrationIp(null);
|
||||
$this->assertNull($account->getRegistrationIp());
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class ClearOauthSessionsTest extends TestCase {
|
||||
$result = ClearOauthSessions::createFromOauthClient($client, time());
|
||||
$this->assertInstanceOf(ClearOauthSessions::class, $result);
|
||||
$this->assertSame('mocked-id', $result->clientId);
|
||||
$this->assertEquals(time(), $result->notSince, '', 1);
|
||||
$this->assertEqualsWithDelta(time(), $result->notSince, 1);
|
||||
}
|
||||
|
||||
public function testExecute() {
|
||||
|
@@ -53,7 +53,7 @@ class DeliveryWebHookTest extends TestCase {
|
||||
$this->assertSame('account.edit', $request->getHeaders()['X-Ely-Accounts-Event'][0]);
|
||||
$this->assertSame('application/x-www-form-urlencoded', $request->getHeaders()['Content-Type'][0]);
|
||||
$this->assertArrayNotHasKey('X-Hub-Signature', $request->getHeaders());
|
||||
$this->assertEquals('key=value&another=value', (string)$request->getBody());
|
||||
$this->assertSame('key=value&another=value', (string)$request->getBody());
|
||||
}
|
||||
|
||||
public function testExecuteSuccessDeliveryWithSignature() {
|
||||
@@ -74,7 +74,7 @@ class DeliveryWebHookTest extends TestCase {
|
||||
$this->assertSame('account.edit', $request->getHeaders()['X-Ely-Accounts-Event'][0]);
|
||||
$this->assertSame('application/x-www-form-urlencoded', $request->getHeaders()['Content-Type'][0]);
|
||||
$this->assertSame('sha1=3c0b1eef564b2d3a5e9c0f2a8302b1b42b3d4784', $request->getHeaders()['X-Hub-Signature'][0]);
|
||||
$this->assertEquals('key=value&another=value', (string)$request->getBody());
|
||||
$this->assertSame('key=value&another=value', (string)$request->getBody());
|
||||
}
|
||||
|
||||
public function testExecuteHandleClientException() {
|
||||
|
@@ -142,7 +142,7 @@ class PullMojangUsernameTest extends TestCase {
|
||||
/** @var MojangUsername|null $mojangUsername */
|
||||
$mojangUsername = MojangUsername::findOne($username);
|
||||
$this->assertInstanceOf(MojangUsername::class, $mojangUsername);
|
||||
$this->assertNotEquals($mojangInfo->uuid, $mojangUsername->uuid);
|
||||
$this->assertNotSame($mojangInfo->uuid, $mojangUsername->uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,18 +26,18 @@ class EmailValidatorTest extends TestCase {
|
||||
|
||||
$model = $this->createModel("testemail@ely.by\u{feff}"); // Zero width no-break space (U+FEFF)
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_invalid'], $model->getErrors('field'));
|
||||
$this->assertEquals('testemail@ely.by', $model->field);
|
||||
$this->assertSame(['error.email_invalid'], $model->getErrors('field'));
|
||||
$this->assertSame('testemail@ely.by', $model->field);
|
||||
}
|
||||
|
||||
public function testValidateAttributeRequired() {
|
||||
$model = $this->createModel('');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_required'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_required'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('email');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_required'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_required'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
public function testValidateAttributeLength() {
|
||||
@@ -49,11 +49,11 @@ class EmailValidatorTest extends TestCase {
|
||||
'@gmail.com' // = 256 symbols
|
||||
);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_too_long'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_too_long'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('some-email@gmail.com');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_too_long'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_too_long'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
public function testValidateAttributeEmail() {
|
||||
@@ -61,15 +61,15 @@ class EmailValidatorTest extends TestCase {
|
||||
|
||||
$model = $this->createModel('non-email');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_invalid'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_invalid'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('non-email@etot-domen-ne-suschestrvyet.de');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_invalid'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_invalid'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('valid-email@gmail.com');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_invalid'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_invalid'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
public function testValidateAttributeTempmail() {
|
||||
@@ -77,11 +77,11 @@ class EmailValidatorTest extends TestCase {
|
||||
|
||||
$model = $this->createModel('ibrpycwyjdnt@dropmail.me');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_is_tempmail'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_is_tempmail'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('valid-email@gmail.com');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_is_tempmail'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_is_tempmail'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
public function testValidateAttributeIdna() {
|
||||
@@ -108,19 +108,19 @@ class EmailValidatorTest extends TestCase {
|
||||
|
||||
$model = $this->createModel($accountFixture->email);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.email_not_available'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.email_not_available'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel($accountFixture->email);
|
||||
$this->validator->accountCallback = function() use ($accountFixture) {
|
||||
return $accountFixture->id;
|
||||
};
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_not_available'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_not_available'], $model->getErrors('field'));
|
||||
$this->validator->accountCallback = null;
|
||||
|
||||
$model = $this->createModel('some-unique-email@gmail.com');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.email_not_available'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.email_not_available'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,18 +11,23 @@ class MinecraftServerAddressValidatorTest extends TestCase {
|
||||
*/
|
||||
public function testValidate($address, $shouldBeValid) {
|
||||
$validator = new MinecraftServerAddressValidator();
|
||||
$validator->message = 'mock message';
|
||||
$validator->validate($address, $errors);
|
||||
$this->assertEquals($shouldBeValid, $errors === null);
|
||||
if ($shouldBeValid) {
|
||||
$this->assertNull($errors);
|
||||
} else {
|
||||
$this->assertSame('mock message', $errors);
|
||||
}
|
||||
}
|
||||
|
||||
public function domainNames() {
|
||||
return [
|
||||
['localhost', true ],
|
||||
['localhost:25565', true ],
|
||||
['mc.hypixel.net', true ],
|
||||
['mc.hypixel.net:25565', true ],
|
||||
['136.243.88.97', true ],
|
||||
['136.243.88.97:25565', true ],
|
||||
['localhost', true],
|
||||
['localhost:25565', true],
|
||||
['mc.hypixel.net', true],
|
||||
['mc.hypixel.net:25565', true],
|
||||
['136.243.88.97', true],
|
||||
['136.243.88.97:25565', true],
|
||||
['http://ely.by', false],
|
||||
['http://ely.by:80', false],
|
||||
['ely.by/abcd', false],
|
||||
|
@@ -21,33 +21,33 @@ class UsernameValidatorTest extends TestCase {
|
||||
public function testValidateTrimming() {
|
||||
$model = $this->createModel("HereIsJohnny#\u{feff}"); // Zero width no-break space (U+FEFF)
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_invalid'], $model->getErrors('field'));
|
||||
$this->assertEquals('HereIsJohnny#', $model->field);
|
||||
$this->assertSame(['error.username_invalid'], $model->getErrors('field'));
|
||||
$this->assertSame('HereIsJohnny#', $model->field);
|
||||
}
|
||||
|
||||
public function testValidateAttributeRequired() {
|
||||
$model = $this->createModel('');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_required'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.username_required'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('username');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_required'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_required'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
public function testValidateAttributeLength() {
|
||||
$model = $this->createModel('at');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_too_short'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.username_too_short'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('erickskrauch_erickskrauch');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_too_long'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.username_too_long'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel('username');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_too_short'], $model->getErrors('field'));
|
||||
$this->assertNotEquals(['error.username_too_long'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_too_short'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_too_long'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
// TODO: rewrite this test with @provider usage
|
||||
@@ -59,7 +59,7 @@ class UsernameValidatorTest extends TestCase {
|
||||
foreach ($shouldBeValid as $nickname) {
|
||||
$model = $this->createModel($nickname);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_invalid'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_invalid'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
$shouldBeInvalid = [
|
||||
@@ -68,7 +68,7 @@ class UsernameValidatorTest extends TestCase {
|
||||
foreach ($shouldBeInvalid as $nickname) {
|
||||
$model = $this->createModel($nickname);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_invalid'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.username_invalid'], $model->getErrors('field'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,19 +82,19 @@ class UsernameValidatorTest extends TestCase {
|
||||
|
||||
$model = $this->createModel($accountFixture->username);
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertEquals(['error.username_not_available'], $model->getErrors('field'));
|
||||
$this->assertSame(['error.username_not_available'], $model->getErrors('field'));
|
||||
|
||||
$model = $this->createModel($accountFixture->username);
|
||||
$this->validator->accountCallback = function() use ($accountFixture) {
|
||||
return $accountFixture->id;
|
||||
};
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_not_available'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_not_available'], $model->getErrors('field'));
|
||||
$this->validator->accountCallback = null;
|
||||
|
||||
$model = $this->createModel('some-unique-username');
|
||||
$this->validator->validateAttribute($model, 'field');
|
||||
$this->assertNotEquals(['error.username_not_available'], $model->getErrors('field'));
|
||||
$this->assertNotSame(['error.username_not_available'], $model->getErrors('field'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,7 +16,7 @@ class UuidValidatorTest extends TestCase {
|
||||
$model = $this->createModel();
|
||||
$validator->validateAttribute($model, 'attribute');
|
||||
$this->assertTrue($model->hasErrors());
|
||||
$this->assertEquals(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
$this->assertSame(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
});
|
||||
|
||||
$this->specify('expected error if passed invalid string', function() {
|
||||
@@ -25,7 +25,7 @@ class UuidValidatorTest extends TestCase {
|
||||
$model->attribute = '123456789';
|
||||
$validator->validateAttribute($model, 'attribute');
|
||||
$this->assertTrue($model->hasErrors());
|
||||
$this->assertEquals(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
$this->assertSame(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed nil uuid and allowNil is set to true', function() {
|
||||
@@ -43,7 +43,7 @@ class UuidValidatorTest extends TestCase {
|
||||
$model->attribute = '00000000-0000-0000-0000-000000000000';
|
||||
$validator->validateAttribute($model, 'attribute');
|
||||
$this->assertTrue($model->hasErrors());
|
||||
$this->assertEquals(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
$this->assertSame(['Attribute must be valid uuid'], $model->getErrors('attribute'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed valid uuid', function() {
|
||||
@@ -61,7 +61,7 @@ class UuidValidatorTest extends TestCase {
|
||||
$model->attribute = str_replace('-', '', $originalUuid);
|
||||
$validator->validateAttribute($model, 'attribute');
|
||||
$this->assertFalse($model->hasErrors());
|
||||
$this->assertEquals($originalUuid, $model->attribute);
|
||||
$this->assertSame($originalUuid, $model->attribute);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user