From 24e126b1978b5c3f7738a5c1e4531c7b3fe2244d Mon Sep 17 00:00:00 2001 From: Sofia Lescano Carroll Date: Tue, 17 Aug 2021 15:24:58 +0200 Subject: [PATCH] feat(graphql): update symfony dependencies to 4.4.*|^5.0 --- composer.json | 10 +++++----- .../ReadGraphQLRateLmitAnnotationListener.php | 3 ++- .../ReadGraphQLRateLmitAnnotationListenerTest.php | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index e1fa8b5..009d50f 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ "php": "7.4.*", "ext-json": "*", "doctrine/annotations": "^1.10.0", - "symfony/config": "4.4.*", - "symfony/dependency-injection": "4.4.*", - "symfony/event-dispatcher": "4.4.*", - "symfony/http-foundation": "4.4.*", - "symfony/http-kernel": "4.4.*", + "symfony/config": "4.4.*|^5.0", + "symfony/dependency-injection": "4.4.*|^5.0", + "symfony/event-dispatcher": "4.4.*|^5.0", + "symfony/http-foundation": "4.4.*|^5.0", + "symfony/http-kernel": "4.4.*|^5.0", "symfony/options-resolver": "^5.0" }, "require-dev": { diff --git a/src/EventListener/ReadGraphQLRateLmitAnnotationListener.php b/src/EventListener/ReadGraphQLRateLmitAnnotationListener.php index 7049010..1d71575 100644 --- a/src/EventListener/ReadGraphQLRateLmitAnnotationListener.php +++ b/src/EventListener/ReadGraphQLRateLmitAnnotationListener.php @@ -106,10 +106,11 @@ public static function getSubscribedEvents(): array } /** - * @param Source|string $query + * @param string|int|float|bool|null $query */ public function extractQueryName($query): string { + /** @var Source $query */ $parsedQuery = Parser::parse($query); /** @var OperationDefinitionNode $item */ foreach ($parsedQuery->definitions->getIterator() as $item) { diff --git a/tests/EventListener/ReadGraphQLRateLmitAnnotationListenerTest.php b/tests/EventListener/ReadGraphQLRateLmitAnnotationListenerTest.php index e200e81..a97c114 100644 --- a/tests/EventListener/ReadGraphQLRateLmitAnnotationListenerTest.php +++ b/tests/EventListener/ReadGraphQLRateLmitAnnotationListenerTest.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ControllerEvent; @@ -64,7 +65,7 @@ public function testItSetsGraphQLRateLimitIfAnnotationProvidedWithDefaultValue() $this->createGraphQLReadRateLimitAnnotationListener(); $request = $this->createMock(Request::class); $request->attributes = new ParameterBag(); - $request->request = new ParameterBag(); + $request->request = new InputBag(); $event = $this->createEventWithGraphQLAnnotation($request, false); $this->container->expects($this->never()) @@ -94,7 +95,7 @@ public function testItSetsGraphQLRateLimitIfAnnotationProvidedWithCustomValue(): $this->createGraphQLReadRateLimitAnnotationListener(); $request = $this->createMock(Request::class); $request->attributes = new ParameterBag(); - $request->request = new ParameterBag(); + $request->request = new InputBag(); $event = $this->createEventWithGraphQLAnnotation($request, true); $this->container->expects($this->never()) @@ -124,7 +125,7 @@ public function testIttDoesNotSetRateLimitIfGraphQLAnnotationAndEndpointNotConfi $this->createGraphQLReadRateLimitAnnotationListener(); $request = $this->createMock(Request::class); $request->attributes = new ParameterBag(); - $request->request = new ParameterBag(); + $request->request = new InputBag(); $event = $this->createEventWithGraphQLAnnotation($request, false); $this->container->expects($this->never()) @@ -147,7 +148,7 @@ public function testItSetsGraphQLRateLimitIfPackageNotInstalled(): void $this->createGraphQLReadRateLimitAnnotationListener(); $request = $this->createMock(Request::class); $request->attributes = new ParameterBag(); - $request->request = new ParameterBag(); + $request->request = new InputBag(); $event = $this->createEventWithGraphQLAnnotation($request, false); $this->annotationReader->expects($this->once())->method('getMethodAnnotation')->willReturn(new GraphQLRateLimitAnnotation(['endpoints' => [['endpoint' => 'GetObject']]]));