From b328dd50a0c99295033c347558606638a48b6c67 Mon Sep 17 00:00:00 2001 From: jochemgravendeel Date: Wed, 30 Oct 2024 13:55:01 +0100 Subject: [PATCH] feat: add tests --- .../PostNl/PostNLReceiptCodeCalculator.php | 2 +- .../PostNLReceiptCodeCalculatorTest.php | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/Unit/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculatorTest.php diff --git a/src/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculator.php b/src/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculator.php index 7fb473de7..4d45540ec 100644 --- a/src/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculator.php +++ b/src/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculator.php @@ -35,7 +35,7 @@ public function calculate(): void $shipmentOptions->largeFormat = TriStateService::DISABLED; $shipmentOptions->return = TriStateService::DISABLED; - if ($shipmentOptions->insurance <= TriStateService::ENABLED) { + if ($shipmentOptions->insurance <= 1) { $shipmentOptions->insurance = 10000; } } diff --git a/tests/Unit/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculatorTest.php b/tests/Unit/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculatorTest.php new file mode 100644 index 000000000..06d9357f5 --- /dev/null +++ b/tests/Unit/App/Order/Calculator/PostNl/PostNLReceiptCodeCalculatorTest.php @@ -0,0 +1,47 @@ +withShippingAddress(['cc' => 'NL']) + ->withDeliveryOptions( + factory(DeliveryOptions::class) + ->withShipmentOptions( + factory(ShipmentOptions::class) + ->withSignature(TriStateService::ENABLED) + ->withOnlyRecipient(TriStateService::ENABLED) + ->withLargeFormat(TriStateService::ENABLED) + ->withReturn(TriStateService::ENABLED) + ->withReceiptCode(TriStateService::ENABLED) + ) + ) + ->make(); + + $calculator = new PostNLReceiptCodeCalculator($order); + $calculator->calculate(); + + $shipmentOptions = $order->deliveryOptions->shipmentOptions; + + expect($shipmentOptions->signature)->toBe(TriStateService::DISABLED) + ->and($shipmentOptions->onlyRecipient)->toBe(TriStateService::DISABLED) + ->and($shipmentOptions->largeFormat)->toBe(TriStateService::DISABLED) + ->and($shipmentOptions->return)->toBe(TriStateService::DISABLED); + + $reset(); +}); \ No newline at end of file