Skip to content

Commit

Permalink
MOL-1196: fix pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Nov 27, 2023
1 parent cfd494e commit d5d81db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/Facade/MollieShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function setShipment(string $orderDeliveryId, Context $context): bool
$lastTransaction = $this->extractor->extractLastMolliePayment($order->getTransactions());

if (!$lastTransaction instanceof OrderTransactionEntity) {

$this->logger->info(
sprintf(
'The last transaction of the order (%s) is not a mollie payment! No shipment will be sent to mollie',
Expand All @@ -170,7 +171,9 @@ public function setShipment(string $orderDeliveryId, Context $context): bool

return false;
}

$trackingInfoStruct = $this->createTrackingInfoStructFromDelivery($delivery);

$addedMollieShipment = $this->mollieApiOrderService->setShipment($mollieOrderId, $trackingInfoStruct, $order->getSalesChannelId());

if ($addedMollieShipment) {
Expand Down Expand Up @@ -467,11 +470,14 @@ private function findMatchingLineItems(OrderEntity $order, string $itemIdentifie
private function createTrackingInfoStructFromDelivery(OrderDeliveryEntity $orderDeliveryEntity):?ShipmentTrackingInfoStruct{
$trackingCodes = $orderDeliveryEntity->getTrackingCodes();
$shippingMethod = $orderDeliveryEntity->getShippingMethod();
if (count($trackingCodes) !== 1 && ! $shippingMethod instanceof ShippingMethodEntity) {
if($shippingMethod === null){
return null;
}
if (count($trackingCodes) !== 1) {
return null;
}

return $this->createTrackingInfoStruct($shippingMethod->getName(),$trackingCodes[0], $shippingMethod->getTrackingUrl());
return $this->createTrackingInfoStruct((string)$shippingMethod->getName(),$trackingCodes[0], (string)$shippingMethod->getTrackingUrl());
}

private function createTrackingInfoStruct(string $trackingCarrier, string $trackingCode, string $trackingUrl): ?ShipmentTrackingInfoStruct
Expand Down
5 changes: 3 additions & 2 deletions tests/PHPUnit/Facade/MollieShipment/SetShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function testThatOrderDeliveryCustomFieldsAreNotWrittenWhenApiCallUnsucce
$deliveryId = $delivery->getId();
$this->orderDeliveryService->method('getDelivery')->willReturn($delivery);
$this->mollieApiOrderService->method('setShipment')
->with($mollieOrderId, $salesChannelId)
->with($mollieOrderId, null, $salesChannelId)
->willReturn(false);

// custom fields for shipping are never written
Expand All @@ -201,6 +201,7 @@ public function testThatOrderDeliveryCustomFieldsAreNotWrittenWhenApiCallUnsucce
public function testThatOrderDeliveryCustomFieldsAreWrittenWhenApiCallSuccessful(): void
{
$transaction = $this->createTransaction('Kiener\MolliePayments\Handler\Method\FooMethod');

$order = $this->createOrder($transaction);
$mollieOrderId = 'foo';
$customFields[CustomFieldsInterface::MOLLIE_KEY][CustomFieldsInterface::ORDER_KEY] = $mollieOrderId;
Expand All @@ -215,7 +216,7 @@ public function testThatOrderDeliveryCustomFieldsAreWrittenWhenApiCallSuccessful
$deliveryId = $delivery->getId();
$this->orderDeliveryService->method('getDelivery')->willReturn($delivery);
$this->mollieApiOrderService->method('setShipment')
->with($mollieOrderId, $salesChannelId)
->with($mollieOrderId, null,$salesChannelId)
->willReturn(true);

// custom fields for shipping are written
Expand Down

0 comments on commit d5d81db

Please sign in to comment.