Update ely/php-code-style and run updated CS fixer

This commit is contained in:
ErickSkrauch
2019-02-26 02:26:02 +03:00
parent ea4ebd19ef
commit b20825a051
67 changed files with 250 additions and 252 deletions

View File

@@ -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'));
}
/**

View File

@@ -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],

View File

@@ -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'));
}
/**

View File

@@ -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);
});
}