diff --git a/.gitignore b/.gitignore index 57872d0..3ffdd8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /vendor/ +.phpunit.result.cache +composer.lock diff --git a/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/Serializer/Normalizer/ConstraintViolationListNormalizer.php index 589259b..f67583a 100644 --- a/Serializer/Normalizer/ConstraintViolationListNormalizer.php +++ b/Serializer/Normalizer/ConstraintViolationListNormalizer.php @@ -12,8 +12,6 @@ namespace StfalconStudio\ApiBundle\Serializer\Normalizer; -use Symfony\Component\Serializer\Debug\TraceableNormalizer; -use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer as SymfonyConstraintViolationListNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Validator\ConstraintViolationListInterface; @@ -23,9 +21,9 @@ class ConstraintViolationListNormalizer implements NormalizerInterface { /** - * @param SymfonyConstraintViolationListNormalizer|TraceableNormalizer $symfonyConstraintViolationListNormalizer + * @param NormalizerInterface $symfonyConstraintViolationListNormalizer */ - public function __construct(private readonly SymfonyConstraintViolationListNormalizer|TraceableNormalizer $symfonyConstraintViolationListNormalizer) + public function __construct(private readonly NormalizerInterface $symfonyConstraintViolationListNormalizer) { } diff --git a/Tests/EventListener/Kernel/ApiExceptionFormatterListenerTest.php b/Tests/EventListener/Kernel/ApiExceptionFormatterListenerTest.php index 4b2fe70..c984942 100644 --- a/Tests/EventListener/Kernel/ApiExceptionFormatterListenerTest.php +++ b/Tests/EventListener/Kernel/ApiExceptionFormatterListenerTest.php @@ -14,6 +14,7 @@ use Doctrine\ODM\MongoDB\LockException; use Doctrine\ORM\OptimisticLockException; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Sentry\ClientInterface; @@ -278,7 +279,7 @@ public function testOnKernelExceptionOnPaymentRequired(): void self::assertInstanceOf(HttpException::class, $exceptionEvent->getThrowable()); } - public function resourceNotFoundExceptionMessageDataProvider(): array + public static function resourceNotFoundExceptionMessageDataProvider(): array { return [ ['"App\\Entity\\Event\\Event\" object not found by \"Symfony\\Bridge\\Doctrine\\ArgumentResolver\\EntityValueResolver\". The expression \"repository.findClosedEventById(id)\" returned null.'], @@ -286,7 +287,7 @@ public function resourceNotFoundExceptionMessageDataProvider(): array ]; } - /** @dataProvider resourceNotFoundExceptionMessageDataProvider */ + #[DataProvider('resourceNotFoundExceptionMessageDataProvider')] public function testOnKernelExceptionWhenResourceNotFoundCausedByMapEntityAttribute(string $exceptionMessage): void { $httpException = new NotFoundHttpException($exceptionMessage); diff --git a/Tests/Serializer/Normalizer/ConstraintViolationListNormalizerTest.php b/Tests/Serializer/Normalizer/ConstraintViolationListNormalizerTest.php index d3934ff..1c79fc5 100644 --- a/Tests/Serializer/Normalizer/ConstraintViolationListNormalizerTest.php +++ b/Tests/Serializer/Normalizer/ConstraintViolationListNormalizerTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use StfalconStudio\ApiBundle\Serializer\Normalizer\ConstraintViolationListNormalizer; -use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer as SymfonyConstraintViolationListNormalizer; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface as SymfonyConstraintViolationListNormalizer; use Symfony\Component\Validator\ConstraintViolationListInterface; final class ConstraintViolationListNormalizerTest extends TestCase @@ -61,20 +61,20 @@ public function testNormalize(string $originDetail, string $resultDetail): void public static function dataProviderForTestNormalize(): iterable { yield [ - 'origin_detail' => 'field1: Error description.', - 'result_detail' => 'Error description.', + 'originDetail' => 'field1: Error description.', + 'resultDetail' => 'Error description.', ]; yield [ - 'origin_detail' => "field1: Error description 1.\nfield2: Error description 2.", - 'result_detail' => "Error description 1.\nError description 2.", + 'originDetail' => "field1: Error description 1.\nfield2: Error description 2.", + 'resultDetail' => "Error description 1.\nError description 2.", ]; yield [ - 'origin_detail' => 'Error description.', - 'result_detail' => 'Error description.', + 'originDetail' => 'Error description.', + 'resultDetail' => 'Error description.', ]; yield [ - 'origin_detail' => "field1: Error :description 1.\nfield2: Error :description 2.", - 'result_detail' => "Error :description 1.\nError :description 2.", + 'originDetail' => "field1: Error :description 1.\nfield2: Error :description 2.", + 'resultDetail' => "Error :description 1.\nError :description 2.", ]; } diff --git a/Tests/Validator/JsonSchemaValidatorTest.php b/Tests/Validator/JsonSchemaValidatorTest.php index 69610d1..868b404 100644 --- a/Tests/Validator/JsonSchemaValidatorTest.php +++ b/Tests/Validator/JsonSchemaValidatorTest.php @@ -109,7 +109,7 @@ public function testInvalidJsonSchemaException(): void 2 => [$dummyJsonSchema, 'object'] }; }) - ->will(self::onConsecutiveCalls($violations, $normalizedJsonSchema)) + ->willReturn($violations, $normalizedJsonSchema) ; $this->expectException(InvalidJsonSchemaException::class);