Skip to content

Commit

Permalink
Missing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ropczan committed Apr 19, 2024
1 parent 780bfd9 commit 4df42e3
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions tests/Unit/Action/CancelActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,42 @@ public function emptyOrderIdInDetails(): void
$action->execute($request);
}

/**
* @test
*/
public function emptyOrderId(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('OrderId must be set on cancel action.');

$action = $this->getCancelAction(null, null);

$details = FileTestUtil::decodeJsonFromFile(__DIR__ . '/../../Integration/Action/data/detailsWithOrderId.json');
$details['orderId'] = null;

$payment = new Payment();
$payment->setConfigKey('pos2');
$payment->setDetails($details);

$request = new Cancel($payment);
$request->setModel($payment->getDetails());

$action->execute($request);
}

private function getCancelAction(
?OrderCanceledResponse $orderCanceledResponse,
OrderRetrieveResponse $retrieveOrderResponse
?OrderRetrieveResponse $retrieveOrderResponse
): CancelAction {
$orderRequestService = $this->createMock(OrderRequestService::class);
$orderRequestService->expects(self::once())
->method('retrieve')
->willReturn($retrieveOrderResponse);
if (null === $retrieveOrderResponse) {
$orderRequestService->expects(self::never())
->method('retrieve');
} else {
$orderRequestService->expects(self::once())
->method('retrieve')
->willReturn($retrieveOrderResponse);
}

if (null === $orderCanceledResponse) {
$orderRequestService->expects(self::never())
Expand Down

0 comments on commit 4df42e3

Please sign in to comment.