Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Jan 10, 2024
1 parent 18d1140 commit c5f09b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions GraphQL/Resolver/General/MolliePaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5f09b3

Please sign in to comment.