From 95b499b6279c6e2732ec8f2cb665b10a9f9cd719 Mon Sep 17 00:00:00 2001 From: Henrique Moody Date: Mon, 4 Feb 2019 02:14:03 +0100 Subject: [PATCH] Apply "phpstan/phpstan-deprecation-rules" rules Signed-off-by: Henrique Moody --- composer.json | 1 + phpstan.neon.dist | 1 + tests/unit/Rules/AbstractEnvelopeTest.php | 3 +- tests/unit/Rules/AbstractWrapperTest.php | 12 -------- tests/unit/Rules/KeySetTest.php | 36 ----------------------- tests/unit/Rules/SfTest.php | 11 ------- tests/unit/Rules/VatinTest.php | 12 -------- 7 files changed, 4 insertions(+), 72 deletions(-) diff --git a/composer.json b/composer.json index 6a2e7a70..97fefc89 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "malukenho/docheader": "^0.1.4", "mikey179/vfsstream": "^1.6", "phpstan/phpstan": "^0.11", + "phpstan/phpstan-deprecation-rules": "^0.11.0", "phpstan/phpstan-phpunit": "^0.11.0", "phpunit/phpunit": "^7.3", "slevomat/coding-standard": "^5.0", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 42528eec..62340e6d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,5 @@ includes: + - vendor/phpstan/phpstan-deprecation-rules/rules.neon - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/tests/unit/Rules/AbstractEnvelopeTest.php b/tests/unit/Rules/AbstractEnvelopeTest.php index 853865be..1dbba8f6 100644 --- a/tests/unit/Rules/AbstractEnvelopeTest.php +++ b/tests/unit/Rules/AbstractEnvelopeTest.php @@ -15,6 +15,7 @@ namespace Respect\Validation\Rules; use Respect\Validation\Test\TestCase; use Respect\Validation\Validatable; +use function array_intersect_key; /** * @test core @@ -78,6 +79,6 @@ final class AbstractEnvelopeTest extends TestCase $exception = $rule->reportError($input); - self::assertArraySubset($parameters, $exception->getParams()); + self::assertEquals($parameters, array_intersect_key($parameters, $exception->getParams())); } } diff --git a/tests/unit/Rules/AbstractWrapperTest.php b/tests/unit/Rules/AbstractWrapperTest.php index 35347258..cafcff90 100644 --- a/tests/unit/Rules/AbstractWrapperTest.php +++ b/tests/unit/Rules/AbstractWrapperTest.php @@ -27,18 +27,6 @@ use Respect\Validation\Validatable; */ final class AbstractWrapperTest extends TestCase { - /** - * @test - */ - public function shouldReturnDefinedValidatable(): void - { - $validatable = $this->createMock(Validatable::class); - - $wrapper = $this->getMockForAbstractClass(AbstractWrapper::class, [$validatable]); - - self::assertAttributeSame($validatable, 'validatable', $wrapper); - } - /** * @test */ diff --git a/tests/unit/Rules/KeySetTest.php b/tests/unit/Rules/KeySetTest.php index 24205a72..56fb3dc5 100644 --- a/tests/unit/Rules/KeySetTest.php +++ b/tests/unit/Rules/KeySetTest.php @@ -27,29 +27,6 @@ use stdClass; */ final class KeySetTest extends TestCase { - /** - * @test - */ - public function shouldAcceptKeyRule(): void - { - $key = new Key('foo', new AlwaysValid(), false); - $keySet = new KeySet($key); - - self::assertAttributeSame([$key], 'keyRules', $keySet); - } - - /** - * @test - */ - public function shouldAcceptAllOfWithOneKeyRule(): void - { - $key = new Key('foo', new AlwaysValid(), false); - $allOf = new AllOf($key); - $keySet = new KeySet($allOf); - - self::assertAttributeSame([$key], 'keyRules', $keySet); - } - /** * @test * @@ -92,19 +69,6 @@ final class KeySetTest extends TestCase new KeySet($alwaysValid); } - /** - * @test - */ - public function shouldReturnKeys(): void - { - $key1 = new Key('foo', new AlwaysValid(), true); - $key2 = new Key('bar', new AlwaysValid(), false); - - $keySet = new KeySet($key1, $key2); - - self::assertAttributeSame(['foo', 'bar'], 'keys', $keySet); - } - /** * @test */ diff --git a/tests/unit/Rules/SfTest.php b/tests/unit/Rules/SfTest.php index a9747fcd..cfff492a 100644 --- a/tests/unit/Rules/SfTest.php +++ b/tests/unit/Rules/SfTest.php @@ -19,7 +19,6 @@ use Symfony\Component\Validator\Constraints\IsFalse; use Symfony\Component\Validator\Constraints\IsNull; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\TraceableValidator; -use Symfony\Component\Validator\Validator\ValidatorInterface; use function class_exists; /** @@ -53,16 +52,6 @@ final class SfTest extends TestCase self::assertFalse($sut->validate(true)); } - /** - * @test - */ - public function itShouldHaveTheValidatorByDefault(): void - { - $sut = new Sf(new IsNull()); - - self::assertAttributeInstanceOf(ValidatorInterface::class, 'validator', $sut); - } - /** * @test */ diff --git a/tests/unit/Rules/VatinTest.php b/tests/unit/Rules/VatinTest.php index 6b9931e8..10fd3391 100644 --- a/tests/unit/Rules/VatinTest.php +++ b/tests/unit/Rules/VatinTest.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Respect\Validation\Rules; use Respect\Validation\Test\RuleTestCase; -use Respect\Validation\Validatable; use stdClass; /** @@ -64,17 +63,6 @@ final class VatinTest extends RuleTestCase ]; } - /** - * @test - */ - public function shouldAcceptCountryCodeOnConstructor(): void - { - $countryCode = 'PL'; - $rule = new Vatin($countryCode); - - self::assertAttributeInstanceOf(Validatable::class, 'validatable', $rule); - } - /** * @expectedException \Respect\Validation\Exceptions\ComponentException * @expectedExceptionMessage "BR" is not a supported country code