Skip to content

Commit

Permalink
test: add test and update relevant snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen committed Jan 21, 2025
1 parent 0be65ce commit 4f6311c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Unit/App/Action/Backend/Order/ExportOrderActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use MyParcelNL\Pdk\Shipment\Model\DeliveryOptions;
use MyParcelNL\Pdk\Shipment\Model\RetailLocation;
use MyParcelNL\Pdk\Shipment\Model\RetailLocationFactory;
use MyParcelNL\Pdk\Tests\Api\Response\ExampleGetShipmentLabelsLinkResponse;
use MyParcelNL\Pdk\Tests\Api\Response\ExampleGetShipmentLabelsLinkV2Response;
use MyParcelNL\Pdk\Tests\Api\Response\ExampleGetShipmentsResponse;
use MyParcelNL\Pdk\Tests\Api\Response\ExamplePostOrderNotesResponse;
Expand All @@ -52,6 +53,40 @@
'order mode' => [true],
]);

dataset('action type toggle', [
'auto' => 'automatic',
'manual' => 'manual',
]);

it('remembers whether it was auto exported', function (string $actionType) {
$orderFactory = factory(PdkOrderCollection::class)->push(
factory(PdkOrder::class)
->withDeliveryOptions(
factory(DeliveryOptions::class)
->withCarrier(Carrier::CARRIER_UPS_NAME)
->withDeliveryType(DeliveryOptions::DELIVERY_TYPE_EXPRESS_NAME)
)
->toTheNetherlands()
);
$orders = new Collection($orderFactory->make());

$orderFactory->store();

MockApi::enqueue(new ExamplePostShipmentsResponse());
MockApi::enqueue(new ExampleGetShipmentLabelsLinkResponse());
MockApi::enqueue(new ExamplePostShipmentsResponse());
MockApi::enqueue(new ExampleGetShipmentLabelsLinkResponse());

$response = Actions::execute(PdkBackendActions::EXPORT_ORDERS, [
'actionType' => $actionType,
'orderIds' => $orders
->pluck('externalIdentifier')
->toArray(),
]);
expect(json_decode($response->getContent(), false)->data->orders[0]->autoExported)->toBe('automatic' === $actionType);
})
->with('action type toggle');

it('exports order', function (
bool $orderMode,
CarrierSettingsFactory $carrierSettingsFactory,
Expand Down

0 comments on commit 4f6311c

Please sign in to comment.