From c5f09b39da417214d42cb6dec9be2bd0322617f1 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Wed, 10 Jan 2024 13:16:06 +0100 Subject: [PATCH] Fix tests --- GraphQL/Resolver/General/MolliePaymentMethods.php | 4 ++-- .../GraphQL/Resolver/General/MolliePaymentMethodsTest.php | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GraphQL/Resolver/General/MolliePaymentMethods.php b/GraphQL/Resolver/General/MolliePaymentMethods.php index 31d435fd241..a254eb68f80 100644 --- a/GraphQL/Resolver/General/MolliePaymentMethods.php +++ b/GraphQL/Resolver/General/MolliePaymentMethods.php @@ -64,7 +64,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value } $storeId = $context->getExtensionAttributes()->getStore()->getId(); - $apiMethods = $this->getMethods($amount, $currency, $storeId); + $apiMethods = $this->getMethods($amount, $currency, $storeId) ?? []; $methods = []; /** @var Method $method */ @@ -90,7 +90,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value ]; } - public function getMethods(float $amount, ?string $currency, int $storeId): MethodCollection + public function getMethods(float $amount, ?string $currency, int $storeId): ?MethodCollection { $mollieApiClient = $this->mollieApiClient->loadByStore($storeId); diff --git a/Test/Integration/GraphQL/Resolver/General/MolliePaymentMethodsTest.php b/Test/Integration/GraphQL/Resolver/General/MolliePaymentMethodsTest.php index a3f6cdafcc7..44d1109f60e 100644 --- a/Test/Integration/GraphQL/Resolver/General/MolliePaymentMethodsTest.php +++ b/Test/Integration/GraphQL/Resolver/General/MolliePaymentMethodsTest.php @@ -150,8 +150,14 @@ private function callEndpoint($methods): array { $this->loadFakeEncryptor()->addReturnValue('', 'test_dummyapikeythatisvalidandislongenough'); + $methodCollection = new \Mollie\Api\Resources\MethodCollection(count($methods), null); + foreach ($methods as $method) { + $methodCollection[] = $method; + } + $methodsEndpointMock = $this->createMock(MethodEndpoint::class); - $methodsEndpointMock->method('allActive')->willReturn($methods); + $methodsEndpointMock->method('allActive')->willReturn($methodCollection); + $methodsEndpointMock->method('allAvailable')->willReturn($methodCollection); $mollieApiMock = $this->createMock(MollieApiClient::class); $mollieApiMock->methods = $methodsEndpointMock;