From 38db1dc8b0ebebc19b3c5fcb56da68cb5ef0ca16 Mon Sep 17 00:00:00 2001 From: Denys Sokolov Date: Thu, 5 Sep 2024 16:02:29 +0200 Subject: [PATCH] ACP-3558 Merchant payment expense support. (#11048) ACP-3558 Merchant payment expense support. --- composer.json | 1 + psalm-report.json | 95 +- .../sales_payment_merchant.transfer.xml | 30 +- .../Business/Expander/OrderItemExpander.php | 123 - .../PaymentTransmissionItemExpander.php | 96 + ...mentTransmissionItemExpanderInterface.php} | 10 +- .../Merchant/AbstractMerchantTransfer.php | 126 +- .../Calculator/MerchantPayoutCalculator.php | 25 - .../MerchantPayoutCalculatorInterface.php | 8 - .../Checker/PaymentMethodPayoutChecker.php | 2 +- .../Merchant/Payout/MerchantPayout.php | 36 +- .../PaymentMethodPayoutReverseChecker.php | 2 +- .../Merchant/Refund/MerchantPayoutReverse.php | 71 +- .../Reader/AbstractOrderExpenseReader.php | 130 + .../Business/Reader/OrderExpenseReader.php | 95 + .../Reader/OrderExpenseReaderInterface.php | 21 + .../Reader/OrderRefundExpenseReader.php | 142 + .../SalesPaymentMerchantPayoutReader.php | 46 +- ...esPaymentMerchantPayoutReaderInterface.php | 15 +- .../SalesPaymentMerchantBusinessFactory.php | 37 +- .../SalesPaymentMerchantFacadeInterface.php | 11 +- .../MerchantPayoutCommandByItemPlugin.php | 8 +- .../MerchantPayoutCommandByOrderPlugin.php | 8 +- ...rchantPayoutReverseCommandByItemPlugin.php | 7 +- ...chantPayoutReverseCommandByOrderPlugin.php | 7 +- .../SalesPaymentMerchantRepository.php | 6 + .../SalesPaymentMerchantConfig.php | 80 +- .../MerchantPayoutCommandPluginTest.php | 356 ++- .../MerchantRefundCommandPluginTest.php | 449 ++- .../Helper/SalesPaymentMerchantHelper.php | 16 +- ...alesPaymentMerchantCommunicationTester.php | 9 +- ...mentMerchantCommunicationTesterActions.php | 2440 ----------------- .../Zed/SalesPaymentMerchant/codeception.yml | 1 + 33 files changed, 1578 insertions(+), 2931 deletions(-) delete mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpander.php create mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpander.php rename src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/{OrderItemExpanderInterface.php => PaymentTransmissionItemExpanderInterface.php} (55%) create mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/AbstractOrderExpenseReader.php create mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReader.php create mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReaderInterface.php create mode 100644 src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderRefundExpenseReader.php delete mode 100644 tests/SprykerTest/Zed/SalesPaymentMerchant/_support/_generated/SalesPaymentMerchantCommunicationTesterActions.php diff --git a/composer.json b/composer.json index bcc4ae8..9326f9f 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "spryker/oms": "*", "spryker/propel": "*", "spryker/ramsey-uuid": "*", + "spryker/store": "*", "spryker/testify": "*" }, "suggest": { diff --git a/psalm-report.json b/psalm-report.json index 6bcd29c..5cf2c8d 100644 --- a/psalm-report.json +++ b/psalm-report.json @@ -1,6 +1,93 @@ { - "error": [], - "warning": [], - "deprecation": [], - "count": 0 + "error": [ + { + "severity": "error", + "line_from": 134, + "line_to": 134, + "type": "InvalidArgument", + "message": "Argument 2 of Spryker\\Zed\\SalesPaymentMerchant\\Persistence\\SalesPaymentMerchantRepository::applySorting expects ArrayObject, but ArrayObject provided", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Persistence/SalesPaymentMerchantRepository.php", + "snippet": " $salesPaymentMerchantPayoutReversalQuery = $this->applySorting($salesPaymentMerchantPayoutReversalQuery, $sortTransfers);", + "selected_text": "$sortTransfers", + "error_level": 6, + "shortcode": 4 + } + ], + "warning": [ + { + "severity": "info", + "line_from": 63, + "line_to": 63, + "type": "PossiblyNullArgument", + "message": "Argument 2 of Spryker\\Zed\\SalesPaymentMerchant\\Business\\Reader\\SalesPaymentMerchantPayoutReaderInterface::getSalesPaymentMerchantPayoutCollectionByMerchantAndOrderReference cannot be null, possibly null value provided", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/Checker/PaymentMethodPayoutChecker.php", + "snippet": " $salesOrderItemTransfer->getMerchantReference(),", + "selected_text": "$salesOrderItemTransfer->getMerchantReference()", + "error_level": 3, + "shortcode": 78 + }, + { + "severity": "info", + "line_from": 63, + "line_to": 63, + "type": "PossiblyNullArgument", + "message": "Argument 2 of Spryker\\Zed\\SalesPaymentMerchant\\Business\\Reader\\SalesPaymentMerchantPayoutReversalReaderInterface::getSalesPaymentMerchantPayoutReversalCollectionByMerchantAndOrderReference cannot be null, possibly null value provided", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/Checker/PaymentMethodPayoutReverseChecker.php", + "snippet": " $salesOrderItemTransfer->getMerchantReference(),", + "selected_text": "$salesOrderItemTransfer->getMerchantReference()", + "error_level": 3, + "shortcode": 78 + }, + { + "severity": "info", + "line_from": 100, + "line_to": 100, + "type": "PossiblyNullArrayOffset", + "message": "Cannot access value on variable $groupedPaymentTransmissionItems[null|string] using possibly null offset null|string", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/MerchantPayoutReverse.php", + "snippet": " $groupedPaymentTransmissionItems[$paymentTransmissionItemTransfer->getTransferId()][] = $paymentTransmissionItemTransfer;", + "selected_text": "$groupedPaymentTransmissionItems", + "error_level": 3, + "shortcode": 125 + }, + { + "severity": "info", + "line_from": 140, + "line_to": 140, + "type": "PossiblyNullOperand", + "message": "Left operand cannot be nullable, got int|null", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderRefundExpenseReader.php", + "snippet": " return $reverseAmount * -1;", + "selected_text": "$reverseAmount", + "error_level": 1, + "shortcode": 80 + } + ], + "deprecation": [ + { + "severity": "info", + "line_from": 139, + "line_to": 139, + "type": "DeprecatedClass", + "message": "Class Generated\\Shared\\Transfer\\OrderItemTransfer is marked as deprecated", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php", + "snippet": " $paymentTransmissionResponseTransfer->getOrderItems();", + "selected_text": "$paymentTransmissionResponseTransfer->getOrderItems()", + "error_level": 2, + "shortcode": 98 + }, + { + "severity": "info", + "line_from": 139, + "line_to": 139, + "type": "DeprecatedMethod", + "message": "The method Generated\\Shared\\Transfer\\PaymentTransmissionResponseTransfer::getOrderItems has been marked as deprecated", + "file_name": "vendor/spryker/spryker/Bundles/SalesPaymentMerchant/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php", + "snippet": " $paymentTransmissionResponseTransfer->getOrderItems();", + "selected_text": "getOrderItems", + "error_level": 2, + "shortcode": 1 + } + ], + "count": 7 } diff --git a/src/Spryker/Shared/SalesPaymentMerchant/Transfer/sales_payment_merchant.transfer.xml b/src/Spryker/Shared/SalesPaymentMerchant/Transfer/sales_payment_merchant.transfer.xml index b1a075c..d940204 100644 --- a/src/Spryker/Shared/SalesPaymentMerchant/Transfer/sales_payment_merchant.transfer.xml +++ b/src/Spryker/Shared/SalesPaymentMerchant/Transfer/sales_payment_merchant.transfer.xml @@ -7,6 +7,8 @@ + + @@ -14,6 +16,7 @@ + @@ -24,7 +27,8 @@ - + + @@ -100,6 +104,9 @@ + + + @@ -117,10 +124,11 @@ - + - + + @@ -142,6 +150,7 @@ + @@ -195,4 +204,19 @@ + + + + + + + + + + + + + + + diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpander.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpander.php deleted file mode 100644 index 7a57f6e..0000000 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpander.php +++ /dev/null @@ -1,123 +0,0 @@ -salesPaymentMerchantPayoutReader = $salesPaymentMerchantPayoutReader; - } - - /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer - * - * @return list<\Generated\Shared\Transfer\OrderItemTransfer> - */ - public function expandOrderItemsWithTransferId( - array $orderItemTransfers, - OrderTransfer $orderTransfer - ): array { - $merchantReferences = $this->extractMerchantReferencesFromOrderItems($orderItemTransfers); - - $salesPaymentMerchantPayoutCollectionTransfer = $this->salesPaymentMerchantPayoutReader->getSalesPaymentMerchantPayoutCollectionByOrderReferenceAndMerchants( - $orderTransfer->getOrderReferenceOrFail(), - $merchantReferences, - ); - - $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId = $this->salesPaymentMerchantPayoutReader - ->getSalesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId($salesPaymentMerchantPayoutCollectionTransfer); - - return $this->mapOrderItemsWithTransferId($orderItemTransfers, $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId); - } - - /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * @param array> $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId - * - * @return list<\Generated\Shared\Transfer\OrderItemTransfer> - */ - protected function mapOrderItemsWithTransferId( - array $orderItemTransfers, - array $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId - ): array { - $orderItemsTransferWithTransferId = []; - - foreach ($orderItemTransfers as $orderItemTransfer) { - $itemReference = $orderItemTransfer->getItemReferenceOrFail(); - $transferId = $this->findTransferIdForItemReference($itemReference, $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId); - - if (!$transferId) { - // We may have entities in the Database that have been failed and do not have a transfer ID. We filter out orderItems that do not have a successful transfer made. - continue; - } - - $orderItemTransfer->setTransferId($transferId); - - $orderItemsTransferWithTransferId[] = $orderItemTransfer; - } - - return $orderItemsTransferWithTransferId; - } - - /** - * @param string $itemReference - * @param array> $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId - * - * @return string|null - */ - protected function findTransferIdForItemReference( - string $itemReference, - array $salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId - ): ?string { - foreach ($salesPaymentMerchantPayoutTransferItemReferencesIndexedByTransferId as $currentTransferId => $itemReferences) { - if (isset($itemReferences[$itemReference])) { - return $currentTransferId; - } - } - - return null; - } - - /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * - * @return list - */ - protected function extractMerchantReferencesFromOrderItems(array $orderItemTransfers): array - { - $merchantReferences = []; - foreach ($orderItemTransfers as $orderItemTransfer) { - $merchantReferences[] = $orderItemTransfer->getMerchantReferenceOrFail(); - } - - return $merchantReferences; - } -} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpander.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpander.php new file mode 100644 index 0000000..d0f8471 --- /dev/null +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpander.php @@ -0,0 +1,96 @@ +salesPaymentMerchantPayoutReader = $salesPaymentMerchantPayoutReader; + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers + * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> + */ + public function expandPaymentTransmissionItemsWithTransferId( + array $paymentTransmissionItemTransfers, + OrderTransfer $orderTransfer + ): array { + $merchantReferences = $this->extractMerchantReferencesFromPaymentTransmissionItems($paymentTransmissionItemTransfers); + + $salesPaymentMerchantPayoutCollectionTransfer = $this->salesPaymentMerchantPayoutReader->getSalesPaymentMerchantPayoutCollectionByOrderReferenceAndMerchants( + $orderTransfer->getOrderReferenceOrFail(), + $merchantReferences, + ); + + $salesPaymentMerchantPayoutTransferIdMapIndexedByItemReference = $this->salesPaymentMerchantPayoutReader + ->getSalesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference($salesPaymentMerchantPayoutCollectionTransfer); + + return $this->mapPaymentTransmissionItemsWithTransferId($paymentTransmissionItemTransfers, $salesPaymentMerchantPayoutTransferIdMapIndexedByItemReference); + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers + * @param array $salesPaymentMerchantPayoutTransferIdMapIndexedByItemReference + * + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> + */ + protected function mapPaymentTransmissionItemsWithTransferId( + array $paymentTransmissionItemTransfers, + array $salesPaymentMerchantPayoutTransferIdMapIndexedByItemReference + ): array { + $paymentTransmissionItemTransfersWithTransferId = []; + foreach ($paymentTransmissionItemTransfers as $paymentTransmissionItemTransfer) { + $transferId = $salesPaymentMerchantPayoutTransferIdMapIndexedByItemReference[$paymentTransmissionItemTransfer->getItemReferenceOrFail()] ?? null; + + if (!$transferId) { + // We may have entities in the Database that have been failed and do not have a transfer ID. We filter out payment transmission items that do not have a successful transfer made. + continue; + } + + $paymentTransmissionItemTransfer->setTransferId($transferId); + $paymentTransmissionItemTransfersWithTransferId[] = $paymentTransmissionItemTransfer; + } + + return $paymentTransmissionItemTransfersWithTransferId; + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers + * + * @return list + */ + protected function extractMerchantReferencesFromPaymentTransmissionItems(array $paymentTransmissionItemTransfers): array + { + $merchantReferences = []; + foreach ($paymentTransmissionItemTransfers as $paymentTransmissionItemTransfer) { + $merchantReferences[] = $paymentTransmissionItemTransfer->getMerchantReferenceOrFail(); + } + + return $merchantReferences; + } +} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpanderInterface.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpanderInterface.php similarity index 55% rename from src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpanderInterface.php rename to src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpanderInterface.php index bfd6edd..7c9924c 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/OrderItemExpanderInterface.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Expander/PaymentTransmissionItemExpanderInterface.php @@ -9,16 +9,16 @@ use Generated\Shared\Transfer\OrderTransfer; -interface OrderItemExpanderInterface +interface PaymentTransmissionItemExpanderInterface { /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * - * @return list<\Generated\Shared\Transfer\OrderItemTransfer> + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> */ - public function expandOrderItemsWithTransferId( - array $orderItemTransfers, + public function expandPaymentTransmissionItemsWithTransferId( + array $paymentTransmissionItemTransfers, OrderTransfer $orderTransfer ): array; } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php index c3f5095..efb72d0 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/AbstractMerchantTransfer.php @@ -8,15 +8,16 @@ namespace Spryker\Zed\SalesPaymentMerchant\Business\Merchant; use Generated\Shared\Transfer\ItemTransfer; -use Generated\Shared\Transfer\OrderExpenseTransfer; -use Generated\Shared\Transfer\OrderItemTransfer; use Generated\Shared\Transfer\OrderTransfer; +use Generated\Shared\Transfer\PaymentTransmissionItemTransfer; use Generated\Shared\Transfer\PaymentTransmissionResponseTransfer; -use Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpanderInterface; +use Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpanderInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Calculator\MerchantPayoutCalculatorInterface; +use Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Reader\TransferEndpointReaderInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Sender\TransferRequestSenderInterface; use Spryker\Zed\SalesPaymentMerchant\Persistence\SalesPaymentMerchantEntityManagerInterface; +use Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig; abstract class AbstractMerchantTransfer { @@ -41,29 +42,45 @@ abstract class AbstractMerchantTransfer protected SalesPaymentMerchantEntityManagerInterface $salesPaymentMerchantEntityManager; /** - * @var \Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpanderInterface + * @var \Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpanderInterface */ - protected OrderItemExpanderInterface $orderItemExpander; + protected PaymentTransmissionItemExpanderInterface $paymentTransmissionItemExpander; + + /** + * @var \Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface + */ + protected OrderExpenseReaderInterface $orderExpenseReader; + + /** + * @var \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig + */ + protected SalesPaymentMerchantConfig $salesPaymentMerchantConfig; /** * @param \Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Calculator\MerchantPayoutCalculatorInterface $merchantPayoutCalculator * @param \Spryker\Zed\SalesPaymentMerchant\Business\Reader\TransferEndpointReaderInterface $transferEndpointReader * @param \Spryker\Zed\SalesPaymentMerchant\Business\Sender\TransferRequestSenderInterface $transferRequestSender * @param \Spryker\Zed\SalesPaymentMerchant\Persistence\SalesPaymentMerchantEntityManagerInterface $salesPaymentMerchantEntityManager - * @param \Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpanderInterface $orderItemExpander + * @param \Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpanderInterface $paymentTransmissionItemExpander + * @param \Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface $orderExpenseReader + * @param \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig $salesPaymentMerchantConfig */ public function __construct( MerchantPayoutCalculatorInterface $merchantPayoutCalculator, TransferEndpointReaderInterface $transferEndpointReader, TransferRequestSenderInterface $transferRequestSender, SalesPaymentMerchantEntityManagerInterface $salesPaymentMerchantEntityManager, - OrderItemExpanderInterface $orderItemExpander + PaymentTransmissionItemExpanderInterface $paymentTransmissionItemExpander, + OrderExpenseReaderInterface $orderExpenseReader, + SalesPaymentMerchantConfig $salesPaymentMerchantConfig ) { $this->merchantPayoutCalculator = $merchantPayoutCalculator; $this->transferEndpointReader = $transferEndpointReader; $this->transferRequestSender = $transferRequestSender; $this->salesPaymentMerchantEntityManager = $salesPaymentMerchantEntityManager; - $this->orderItemExpander = $orderItemExpander; + $this->paymentTransmissionItemExpander = $paymentTransmissionItemExpander; + $this->orderExpenseReader = $orderExpenseReader; + $this->salesPaymentMerchantConfig = $salesPaymentMerchantConfig; } /** @@ -74,84 +91,101 @@ public function __construct( */ abstract protected function calculatePayoutAmount(ItemTransfer $itemTransfer, OrderTransfer $orderTransfer): int; + /** + * @param \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + * + * @return void + */ + abstract protected function savePaymentTransmissionResponse( + PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + ): void; + /** * @param list<\Generated\Shared\Transfer\ItemTransfer> $salesOrderItemTransfers * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer * - * @return list<\Generated\Shared\Transfer\OrderItemTransfer> + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> */ protected function getOrderItemsForTransfer(array $salesOrderItemTransfers, OrderTransfer $orderTransfer): array { - $orderItemTransfers = []; + $orderItemPaymentTransmissionItemTransfers = []; foreach ($salesOrderItemTransfers as $itemTransfer) { if (!$itemTransfer->getMerchantReference()) { continue; } - $orderItemTransfers[] = (new OrderItemTransfer()) + $orderItemPaymentTransmissionItemTransfers[] = (new PaymentTransmissionItemTransfer()) ->fromArray($itemTransfer->toArray(), true) + ->setType(SalesPaymentMerchantConfig::PAYMENT_TRANSMISSION_ITEM_TYPE_ORDER_ITEM) ->setMerchantReference($itemTransfer->getMerchantReferenceOrFail()) ->setOrderReference($orderTransfer->getOrderReferenceOrFail()) ->setItemReference($itemTransfer->getOrderItemReferenceOrFail()) ->setAmount((string)$this->calculatePayoutAmount($itemTransfer, $orderTransfer)); } - return $orderItemTransfers; + return $orderItemPaymentTransmissionItemTransfers; } /** - * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * @param \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer * - * @return list<\Generated\Shared\Transfer\OrderExpenseTransfer> + * @return string */ - protected function getOrderExpensesForTransfer(OrderTransfer $orderTransfer): array - { - $orderExpenseTransfers = []; - foreach ($orderTransfer->getExpenses() as $expenseTransfer) { - $orderExpenseTransfers[] = (new OrderExpenseTransfer()) - ->fromArray($expenseTransfer->toArray(), true) - ->setMerchantReference($expenseTransfer->getMerchantReferenceOrFail()) - ->setOrderReference($orderTransfer->getOrderReferenceOrFail()) - ->setExpenseReference($expenseTransfer->getUuidOrFail()) - ->setAmount((string)$expenseTransfer->getSumPriceToPayAggregationOrFail()); + protected function getItemReferences( + PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + ): string { + $paymentTransmissionItemTransfers = $paymentTransmissionResponseTransfer->getPaymentTransmissionItems()->count() > 0 ? + $paymentTransmissionResponseTransfer->getPaymentTransmissionItems() : + $paymentTransmissionResponseTransfer->getOrderItems(); + + $itemReferences = []; + foreach ($paymentTransmissionItemTransfers as $paymentTransmissionItemTransfer) { + $itemReferences[] = $paymentTransmissionItemTransfer->getItemReferenceOrFail(); } - return $orderExpenseTransfers; + return implode(',', $itemReferences); } /** - * @param \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers + * @param string $transferEndpointUrl * - * @return string + * @return void */ - protected function getItemReferences(PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer): string - { - $itemReferences = []; - - foreach ($paymentTransmissionResponseTransfer->getOrderItems() as $orderItemTransfer) { - $itemReferences[] = $orderItemTransfer->getItemReferenceOrFail(); + protected function executePayoutTransmissionTransaction( + array $paymentTransmissionItemTransfers, + string $transferEndpointUrl + ): void { + $transferRequestData = $this->createTransferRequestData($paymentTransmissionItemTransfers); + $paymentTransmissionResponseCollectionTransfer = $this->transferRequestSender->requestTransfer( + $transferRequestData, + $transferEndpointUrl, + ); + + /** @var \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer */ + foreach ($paymentTransmissionResponseCollectionTransfer->getPaymentTransmissions() as $paymentTransmissionResponseTransfer) { + $paymentTransmissionResponseTransfer->setItemReferences($this->getItemReferences($paymentTransmissionResponseTransfer)); + + $this->savePaymentTransmissionResponse($paymentTransmissionResponseTransfer); } - - return implode(',', $itemReferences); } /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * @param list<\Generated\Shared\Transfer\OrderExpenseTransfer> $orderExpenseTransfers + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $paymentTransmissionItemTransfers * * @return array>|int> */ - protected function createTransferRequestData(array $orderItemTransfers, array $orderExpenseTransfers): array - { - $orderAmountTotal = $this->merchantPayoutCalculator->calculatePayoutAmountForOrder($orderItemTransfers, $orderExpenseTransfers); - - $orderItemTransfersArray = array_map(fn ($itemTransfer) => $itemTransfer->toArray(), $orderItemTransfers); - $orderExpenseTransfersArray = array_map(fn ($expenseTransfer) => $expenseTransfer->toArray(), $orderExpenseTransfers); + protected function createTransferRequestData( + array $paymentTransmissionItemTransfers + ): array { + $paymentTransmissionItemTransfersArray = array_map( + fn (PaymentTransmissionItemTransfer $paymentTransmissionItem) => $paymentTransmissionItem->toArray(), + $paymentTransmissionItemTransfers, + ); return [ - 'orderItems' => $orderItemTransfersArray, - 'orderExpenses' => $orderExpenseTransfersArray, - 'orderAmountTotal' => $orderAmountTotal, + 'orderItems' => $paymentTransmissionItemTransfersArray, + 'paymentTransmissionItems' => $paymentTransmissionItemTransfersArray, ]; } } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculator.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculator.php index 8b4dfde..9ab9d25 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculator.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculator.php @@ -13,11 +13,6 @@ class MerchantPayoutCalculator implements MerchantPayoutCalculatorInterface { - /** - * @var string - */ - protected const FIELD_NAME_AMOUNT = 'amount'; - /** * @var \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface|null */ @@ -54,24 +49,4 @@ public function calculatePayoutAmount(ItemTransfer $itemTransfer, OrderTransfer return $this->amountCalculatorFallback->calculatePayoutAmount($itemTransfer, $orderTransfer); } - - /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * @param list<\Generated\Shared\Transfer\OrderExpenseTransfer> $orderExpenseTransfers - * - * @return int - */ - public function calculatePayoutAmountForOrder(array $orderItemTransfers, array $orderExpenseTransfers): int - { - $orderAmountTotal = 0; - foreach ($orderItemTransfers as $orderItemTransfer) { - $orderAmountTotal += $orderItemTransfer->getAmount() ?? 0; - } - - foreach ($orderExpenseTransfers as $orderExpenseTransfer) { - $orderAmountTotal += $orderExpenseTransfer->getAmount() ?? 0; - } - - return $orderAmountTotal; - } } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculatorInterface.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculatorInterface.php index a182da9..42c7d50 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculatorInterface.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Calculator/MerchantPayoutCalculatorInterface.php @@ -19,12 +19,4 @@ interface MerchantPayoutCalculatorInterface * @return int */ public function calculatePayoutAmount(ItemTransfer $itemTransfer, OrderTransfer $orderTransfer): int; - - /** - * @param list<\Generated\Shared\Transfer\OrderItemTransfer> $orderItemTransfers - * @param list<\Generated\Shared\Transfer\OrderExpenseTransfer> $orderExpenseTransfers - * - * @return int - */ - public function calculatePayoutAmountForOrder(array $orderItemTransfers, array $orderExpenseTransfers): int; } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/Checker/PaymentMethodPayoutChecker.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/Checker/PaymentMethodPayoutChecker.php index 5bf2b44..c983264 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/Checker/PaymentMethodPayoutChecker.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/Checker/PaymentMethodPayoutChecker.php @@ -60,7 +60,7 @@ public function isPayoutSupportedForPaymentMethodUsedForOrder( $salesPaymentMerchantPayoutCollectionTransfer = $this->salesPaymentMerchantPayoutReader->getSalesPaymentMerchantPayoutCollectionByMerchantAndOrderReference( $orderTransfer->getOrderReferenceOrFail(), - $salesOrderItemTransfer->getMerchantReference(), + $salesOrderItemTransfer->getMerchantReferenceOrFail(), true, ); diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/MerchantPayout.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/MerchantPayout.php index 297c94e..691143c 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/MerchantPayout.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Payout/MerchantPayout.php @@ -9,6 +9,7 @@ use Generated\Shared\Transfer\ItemTransfer; use Generated\Shared\Transfer\OrderTransfer; +use Generated\Shared\Transfer\PaymentTransmissionResponseTransfer; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\AbstractMerchantTransfer; class MerchantPayout extends AbstractMerchantTransfer implements MerchantPayoutInterface @@ -26,25 +27,34 @@ public function payoutMerchants(array $salesOrderItemTransfers, OrderTransfer $o return; } - $orderItemTransfers = $this->getOrderItemsForTransfer($salesOrderItemTransfers, $orderTransfer); - - if (count($orderItemTransfers) === 0) { + $orderItemPaymentTransmissionItemTransfers = $this->getOrderItemsForTransfer($salesOrderItemTransfers, $orderTransfer); + if (count($orderItemPaymentTransmissionItemTransfers) === 0) { return; } - $orderExpenseTransfers = $this->getOrderExpensesForTransfer($orderTransfer); - $transferRequestData = $this->createTransferRequestData($orderItemTransfers, $orderExpenseTransfers); + $this->executePayoutTransmissionTransaction($orderItemPaymentTransmissionItemTransfers, $transferEndpointUrl); - $paymentTransmissionResponseCollectionTransfer = $this->transferRequestSender->requestTransfer( - $transferRequestData, - $transferEndpointUrl, - ); - /** @var \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer */ - foreach ($paymentTransmissionResponseCollectionTransfer->getPaymentTransmissions() as $paymentTransmissionResponseTransfer) { - $paymentTransmissionResponseTransfer->setItemReferences($this->getItemReferences($paymentTransmissionResponseTransfer)); + if (!$this->salesPaymentMerchantConfig->isOrderExpenseIncludedInPaymentProcess()) { + return; + } - $this->salesPaymentMerchantEntityManager->saveSalesPaymentMerchantPayout($paymentTransmissionResponseTransfer); + $orderExpensePaymentTransmissionItemTransfers = $this->orderExpenseReader->getOrderExpensesForTransfer($orderTransfer, $orderItemPaymentTransmissionItemTransfers); + if (count($orderExpensePaymentTransmissionItemTransfers) === 0) { + return; } + + $this->executePayoutTransmissionTransaction($orderExpensePaymentTransmissionItemTransfers, $transferEndpointUrl); + } + + /** + * @param \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + * + * @return void + */ + protected function savePaymentTransmissionResponse( + PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + ): void { + $this->salesPaymentMerchantEntityManager->saveSalesPaymentMerchantPayout($paymentTransmissionResponseTransfer); } /** diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/Checker/PaymentMethodPayoutReverseChecker.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/Checker/PaymentMethodPayoutReverseChecker.php index a4a57d0..5aa3681 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/Checker/PaymentMethodPayoutReverseChecker.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/Checker/PaymentMethodPayoutReverseChecker.php @@ -60,7 +60,7 @@ public function isPayoutReversalSupportedForPaymentMethodUsedForOrder( $salesPaymentMerchantPayoutReversalCollectionTransfer = $this->salesPaymentMerchantPayoutReversalReader->getSalesPaymentMerchantPayoutReversalCollectionByMerchantAndOrderReference( $orderTransfer->getOrderReferenceOrFail(), - $salesOrderItemTransfer->getMerchantReference(), + $salesOrderItemTransfer->getMerchantReferenceOrFail(), true, ); diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/MerchantPayoutReverse.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/MerchantPayoutReverse.php index 856f4b3..f58ce02 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/MerchantPayoutReverse.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Merchant/Refund/MerchantPayoutReverse.php @@ -9,6 +9,7 @@ use Generated\Shared\Transfer\ItemTransfer; use Generated\Shared\Transfer\OrderTransfer; +use Generated\Shared\Transfer\PaymentTransmissionResponseTransfer; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\AbstractMerchantTransfer; class MerchantPayoutReverse extends AbstractMerchantTransfer implements MerchantPayoutReverseInterface @@ -22,33 +23,60 @@ class MerchantPayoutReverse extends AbstractMerchantTransfer implements Merchant public function reversePayoutMerchants(array $salesOrderItemTransfers, OrderTransfer $orderTransfer): void { $transferEndpointUrl = $this->transferEndpointReader->getTransferEndpointUrl($orderTransfer); - if (!$transferEndpointUrl) { return; } - $orderItemTransfers = $this->getOrderItemsForTransfer($salesOrderItemTransfers, $orderTransfer); - - if (count($orderItemTransfers) === 0) { + $orderItemPaymentTransmissionItemTransfers = $this->getOrderItemsForTransfer($salesOrderItemTransfers, $orderTransfer); + if (count($orderItemPaymentTransmissionItemTransfers) === 0) { return; } - $orderItemTransfers = $this->orderItemExpander->expandOrderItemsWithTransferId($orderItemTransfers, $orderTransfer); - $orderExpenseTransfers = $this->getOrderExpensesForTransfer($orderTransfer); - $transferRequestData = $this->createTransferRequestData($orderItemTransfers, $orderExpenseTransfers); + $orderItemPaymentTransmissionItemTransfers = $this->paymentTransmissionItemExpander + ->expandPaymentTransmissionItemsWithTransferId($orderItemPaymentTransmissionItemTransfers, $orderTransfer); + $this->executeGroupedPayoutTransmissionTransaction($orderItemPaymentTransmissionItemTransfers, $transferEndpointUrl); - $paymentTransmissionResponseCollectionTransfer = $this->transferRequestSender->requestTransfer( - $transferRequestData, - $transferEndpointUrl, - ); + if (!$this->salesPaymentMerchantConfig->isOrderExpenseIncludedInPaymentProcess()) { + return; + } - foreach ($paymentTransmissionResponseCollectionTransfer->getPaymentTransmissions() as $paymentTransmissionResponseTransfer) { - $paymentTransmissionResponseTransfer->setItemReferences($this->getItemReferences($paymentTransmissionResponseTransfer)); + $orderExpensePaymentTransmissionItemTransfers = $this->orderExpenseReader->getOrderExpensesForTransfer($orderTransfer, $orderItemPaymentTransmissionItemTransfers); + if (count($orderExpensePaymentTransmissionItemTransfers) === 0) { + return; + } - $this->salesPaymentMerchantEntityManager->saveSalesPaymentMerchantPayoutReversal($paymentTransmissionResponseTransfer); + $orderExpensePaymentTransmissionItemTransfers = $this->paymentTransmissionItemExpander + ->expandPaymentTransmissionItemsWithTransferId($orderExpensePaymentTransmissionItemTransfers, $orderTransfer); + $this->executePayoutTransmissionTransaction($orderExpensePaymentTransmissionItemTransfers, $transferEndpointUrl); + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * @param string $transferEndpointUrl + * + * @return void + */ + public function executeGroupedPayoutTransmissionTransaction( + array $orderItemPaymentTransmissionItemTransfers, + string $transferEndpointUrl + ): void { + $groupedPaymentTransmissionItemsByTransferId = $this->groupPaymentTransmissionItemsByTransferId($orderItemPaymentTransmissionItemTransfers); + foreach ($groupedPaymentTransmissionItemsByTransferId as $paymentTransmissionItemTransfers) { + $this->executePayoutTransmissionTransaction($paymentTransmissionItemTransfers, $transferEndpointUrl); } } + /** + * @param \Generated\Shared\Transfer\PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + * + * @return void + */ + protected function savePaymentTransmissionResponse( + PaymentTransmissionResponseTransfer $paymentTransmissionResponseTransfer + ): void { + $this->salesPaymentMerchantEntityManager->saveSalesPaymentMerchantPayoutReversal($paymentTransmissionResponseTransfer); + } + /** * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer @@ -59,4 +87,19 @@ protected function calculatePayoutAmount(ItemTransfer $itemTransfer, OrderTransf { return $this->merchantPayoutCalculator->calculatePayoutAmount($itemTransfer, $orderTransfer) * -1; } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return array> + */ + protected function groupPaymentTransmissionItemsByTransferId(array $orderItemPaymentTransmissionItemTransfers): array + { + $groupedPaymentTransmissionItems = []; + foreach ($orderItemPaymentTransmissionItemTransfers as $paymentTransmissionItemTransfer) { + $groupedPaymentTransmissionItems[$paymentTransmissionItemTransfer->getTransferIdOrFail()][] = $paymentTransmissionItemTransfer; + } + + return $groupedPaymentTransmissionItems; + } } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/AbstractOrderExpenseReader.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/AbstractOrderExpenseReader.php new file mode 100644 index 0000000..0054591 --- /dev/null +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/AbstractOrderExpenseReader.php @@ -0,0 +1,130 @@ +salesPaymentMerchantConfig = $salesPaymentMerchantConfig; + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * @param int $amount + * + * @return \Generated\Shared\Transfer\PaymentTransmissionItemTransfer + */ + protected function createOrderExpensePaymentTransmissionItemTransfer( + ExpenseTransfer $expenseTransfer, + OrderTransfer $orderTransfer, + int $amount + ): PaymentTransmissionItemTransfer { + return (new PaymentTransmissionItemTransfer()) + ->fromArray($expenseTransfer->toArray(), true) + ->setType(SalesPaymentMerchantConfig::PAYMENT_TRANSMISSION_ITEM_TYPE_ORDER_EXPENSE) + ->setMerchantReference($expenseTransfer->getMerchantReferenceOrFail()) + ->setOrderReference($orderTransfer->getOrderReferenceOrFail()) + ->setItemReference($expenseTransfer->getUuidOrFail()) + ->setAmount((string)$amount); + } + + /** + * @param string $storeName + * + * @return array + */ + protected function getExcludedExpenseTypeMap(string $storeName): array + { + $excludedExpenseTypesForStore = $this->salesPaymentMerchantConfig->getExcludedExpenseTypesForStore($storeName); + + return array_combine($excludedExpenseTypesForStore, $excludedExpenseTypesForStore); + } + + /** + * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return list<\Generated\Shared\Transfer\ExpenseTransfer> + */ + protected function filterOutNonApplicableMerchantExpenses( + OrderTransfer $orderTransfer, + array $orderItemPaymentTransmissionItemTransfers + ): array { + $merchantReferenceMap = $this->extractMerchantReferenceMapFromOrderItems($orderItemPaymentTransmissionItemTransfers); + $excludedExpenseTypeMap = $this->getExcludedExpenseTypeMap($orderTransfer->getStoreOrFail()); + + $applicableExpenseTransfers = []; + foreach ($orderTransfer->getExpenses() as $expenseTransfer) { + if ($this->isExpenseExcluded($expenseTransfer, $excludedExpenseTypeMap)) { + continue; + } + + if (!$this->isExpenseRelatedToMerchantAndOrder($expenseTransfer, $merchantReferenceMap)) { + continue; + } + + $applicableExpenseTransfers[] = $expenseTransfer; + } + + return $applicableExpenseTransfers; + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return array + */ + protected function extractMerchantReferenceMapFromOrderItems(array $orderItemPaymentTransmissionItemTransfers): array + { + $merchantReferences = []; + foreach ($orderItemPaymentTransmissionItemTransfers as $orderItemPaymentTransmissionItemTransfer) { + $merchantReference = $orderItemPaymentTransmissionItemTransfer->getMerchantReferenceOrFail(); + $merchantReferences[$merchantReference] = $merchantReference; + } + + return $merchantReferences; + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * @param array $excludedExpenseTypeMap + * + * @return bool + */ + protected function isExpenseExcluded(ExpenseTransfer $expenseTransfer, array $excludedExpenseTypeMap): bool + { + return isset($excludedExpenseTypeMap[$expenseTransfer->getTypeOrFail()]); + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * @param array $merchantReferenceMap + * + * @return bool + */ + protected function isExpenseRelatedToMerchantAndOrder(mixed $expenseTransfer, array $merchantReferenceMap): bool + { + return $expenseTransfer->getMerchantReference() !== null && isset($merchantReferenceMap[$expenseTransfer->getMerchantReference()]); + } +} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReader.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReader.php new file mode 100644 index 0000000..92b1dae --- /dev/null +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReader.php @@ -0,0 +1,95 @@ +salesPaymentMerchantPayoutReader = $salesPaymentMerchantPayoutReader; + } + + /** + * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> + */ + public function getOrderExpensesForTransfer( + OrderTransfer $orderTransfer, + array $orderItemPaymentTransmissionItemTransfers + ): array { + $orderExpensePaymentTransmissionItemTransfers = []; + $expenseTransfers = $this->filterOutNonApplicableMerchantExpenses($orderTransfer, $orderItemPaymentTransmissionItemTransfers); + $expenseItemReferences = $this->extractItemReferencesFromExpenses($expenseTransfers); + + $salesPaymentMerchantPayoutMapByItemReferencesForPaidOutExpenses = $this->salesPaymentMerchantPayoutReader + ->getSalesPaymentMerchantPayoutMapByItemReferences( + $orderTransfer->getOrderReferenceOrFail(), + $expenseItemReferences, + ); + + foreach ($expenseTransfers as $expenseTransfer) { + if ($this->isExpenseHasBeenPaidOut($expenseTransfer, $salesPaymentMerchantPayoutMapByItemReferencesForPaidOutExpenses)) { + continue; + } + + $orderExpensePaymentTransmissionItemTransfers[] = $this->createOrderExpensePaymentTransmissionItemTransfer( + $expenseTransfer, + $orderTransfer, + $expenseTransfer->getSumPriceToPayAggregationOrFail(), + ); + } + + return $orderExpensePaymentTransmissionItemTransfers; + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * @param array $salesPaymentMerchantPayoutMapByItemReferencesForPaidOutExpenses + * + * @return bool + */ + protected function isExpenseHasBeenPaidOut( + ExpenseTransfer $expenseTransfer, + array $salesPaymentMerchantPayoutMapByItemReferencesForPaidOutExpenses + ): bool { + return isset($salesPaymentMerchantPayoutMapByItemReferencesForPaidOutExpenses[$expenseTransfer->getUuidOrFail()]); + } + + /** + * @param list<\Generated\Shared\Transfer\ExpenseTransfer> $expenseTransfers + * + * @return list + */ + protected function extractItemReferencesFromExpenses(array $expenseTransfers): array + { + $itemReferences = []; + foreach ($expenseTransfers as $expenseTransfer) { + $itemReferences[] = $expenseTransfer->getUuidOrFail(); + } + + return $itemReferences; + } +} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReaderInterface.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReaderInterface.php new file mode 100644 index 0000000..d8a2da5 --- /dev/null +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderExpenseReaderInterface.php @@ -0,0 +1,21 @@ + $orderItemPaymentTransmissionItemTransfers + * + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> + */ + public function getOrderExpensesForTransfer(OrderTransfer $orderTransfer, array $orderItemPaymentTransmissionItemTransfers): array; +} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderRefundExpenseReader.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderRefundExpenseReader.php new file mode 100644 index 0000000..00501cd --- /dev/null +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/OrderRefundExpenseReader.php @@ -0,0 +1,142 @@ + $orderItemPaymentTransmissionItemTransfers + * + * @return list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> + */ + public function getOrderExpensesForTransfer( + OrderTransfer $orderTransfer, + array $orderItemPaymentTransmissionItemTransfers + ): array { + $orderExpensePaymentTransmissionItemTransfers = []; + $merchantReferenceMapForUnRefusedItems = $this->getMerchantReferenceMapForUnRefusedItems($orderTransfer, $orderItemPaymentTransmissionItemTransfers); + $expenseTransfers = $this->filterOutNonApplicableMerchantExpenses($orderTransfer, $orderItemPaymentTransmissionItemTransfers); + + foreach ($expenseTransfers as $expenseTransfer) { + if ($this->isExpenseForOrderWithUnrefusedItems($expenseTransfer, $merchantReferenceMapForUnRefusedItems)) { + continue; + } + + $orderExpensePaymentTransmissionItemTransfers[] = $this->createOrderExpensePaymentTransmissionItemTransfer( + $expenseTransfer, + $orderTransfer, + $this->getReverseAmount($expenseTransfer), + ); + } + + return $orderExpensePaymentTransmissionItemTransfers; + } + + /** + * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return array + */ + protected function getMerchantReferenceMapForUnRefusedItems( + OrderTransfer $orderTransfer, + array $orderItemPaymentTransmissionItemTransfers + ): array { + $merchantReferenceMap = []; + $itemRefusedStateMap = array_combine( + $this->salesPaymentMerchantConfig->getItemRefusedStates(), + $this->salesPaymentMerchantConfig->getItemRefusedStates(), + ); + + $orderItemReferenceMap = $this->extractOrderItemReferenceMap($orderItemPaymentTransmissionItemTransfers); + foreach ($orderTransfer->getItems() as $itemTransfer) { + if ($this->isItemInReversePayoutChangeState($orderItemReferenceMap, $itemTransfer)) { + continue; + } + + if ($this->isItemInRefusedState($itemTransfer, $itemRefusedStateMap)) { + continue; + } + + $merchantReference = $itemTransfer->getMerchantReferenceOrFail(); + $merchantReferenceMap[$merchantReference] = $merchantReference; + } + + return $merchantReferenceMap; + } + + /** + * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer + * @param array $itemRefusedStateMap + * + * @return bool + */ + protected function isItemInRefusedState(ItemTransfer $itemTransfer, array $itemRefusedStateMap): bool + { + $itemStateName = $itemTransfer->getStateOrFail()->getNameOrFail(); + + return isset($itemRefusedStateMap[$itemStateName]); + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * @param array $merchantReferenceMapForUnRefusedItems + * + * @return bool + */ + protected function isExpenseForOrderWithUnrefusedItems( + ExpenseTransfer $expenseTransfer, + array $merchantReferenceMapForUnRefusedItems + ): bool { + return isset($merchantReferenceMapForUnRefusedItems[$expenseTransfer->getMerchantReferenceOrFail()]); + } + + /** + * @param list<\Generated\Shared\Transfer\PaymentTransmissionItemTransfer> $orderItemPaymentTransmissionItemTransfers + * + * @return array + */ + protected function extractOrderItemReferenceMap(array $orderItemPaymentTransmissionItemTransfers): array + { + $orderItemReferenceMap = []; + foreach ($orderItemPaymentTransmissionItemTransfers as $orderItemPaymentTransmissionItemTransfer) { + $itemReference = $orderItemPaymentTransmissionItemTransfer->getItemReferenceOrFail(); + $orderItemReferenceMap[$itemReference] = $itemReference; + } + + return $orderItemReferenceMap; + } + + /** + * @param array $orderItemReferenceMap + * @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer + * + * @return bool + */ + protected function isItemInReversePayoutChangeState(array $orderItemReferenceMap, mixed $itemTransfer): bool + { + return isset($orderItemReferenceMap[$itemTransfer->getOrderItemReference()]); + } + + /** + * @param \Generated\Shared\Transfer\ExpenseTransfer $expenseTransfer + * + * @return int + */ + protected function getReverseAmount(ExpenseTransfer $expenseTransfer): int + { + $reverseAmount = $expenseTransfer->getRefundableAmount() !== 0 ? $expenseTransfer->getRefundableAmount() : $expenseTransfer->getCanceledAmountOrFail(); + + return $reverseAmount * -1; + } +} diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReader.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReader.php index d983f4b..cd82b9d 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReader.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReader.php @@ -69,24 +69,54 @@ public function getSalesPaymentMerchantPayoutCollectionByMerchantAndOrderReferen return $this->salesPaymentMerchantRepository->getSalesPaymentMerchantPayoutCollection($salesPaymentMerchantPayoutCriteriaTransfer); } + /** + * @param string $orderReference + * @param list $itemReferences + * + * @return array + */ + public function getSalesPaymentMerchantPayoutMapByItemReferences( + string $orderReference, + array $itemReferences + ): array { + $salesPaymentMerchantPayoutConditionsTransfer = (new SalesPaymentMerchantPayoutConditionsTransfer()) + ->addOrderReference($orderReference) + ->setItemReferences($itemReferences) + ->setIsSuccessful(true); + + $salesPaymentMerchantPayoutCriteriaTransfer = $this->createPaymentMerchantPayoutCriteriaTransfer($salesPaymentMerchantPayoutConditionsTransfer); + $salesPaymentMerchantPayoutCollectionTransfer = $this->salesPaymentMerchantRepository->getSalesPaymentMerchantPayoutCollection($salesPaymentMerchantPayoutCriteriaTransfer); + + $salesPaymentMerchantPayoutMapByItemReferences = []; + foreach ($salesPaymentMerchantPayoutCollectionTransfer->getSalesPaymentMerchantPayouts() as $salesPaymentMerchantPayoutTransfer) { + $salesPaymentMerchantPayoutMapByItemReferences[$salesPaymentMerchantPayoutTransfer->getItemReferencesOrFail()] = $salesPaymentMerchantPayoutTransfer; + } + + return $salesPaymentMerchantPayoutMapByItemReferences; + } + /** * @param \Generated\Shared\Transfer\SalesPaymentMerchantPayoutCollectionTransfer $salesPaymentMerchantPayoutCollectionTransfer * - * @return array> + * @return array */ - public function getSalesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId( + public function getSalesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference( SalesPaymentMerchantPayoutCollectionTransfer $salesPaymentMerchantPayoutCollectionTransfer ): array { - $salesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId = []; - + $salesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference = []; foreach ($salesPaymentMerchantPayoutCollectionTransfer->getSalesPaymentMerchantPayouts() as $salesPaymentMerchantPayoutTransfer) { $transferId = $salesPaymentMerchantPayoutTransfer->getTransferIdOrFail(); - $itemReferences = explode(SalesPaymentMerchantConfig::ITEM_REFERENCE_SEPARATOR, $salesPaymentMerchantPayoutTransfer->getItemReferencesOrFail()); - - $salesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId[$transferId] = array_combine($itemReferences, $itemReferences); + $itemReferences = explode( + SalesPaymentMerchantConfig::ITEM_REFERENCE_SEPARATOR, + $salesPaymentMerchantPayoutTransfer->getItemReferencesOrFail(), + ); + + foreach ($itemReferences as $itemReference) { + $salesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference[$itemReference] = $transferId; + } } - return $salesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId; + return $salesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference; } /** diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReaderInterface.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReaderInterface.php index dc4414b..a7d7943 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReaderInterface.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/Reader/SalesPaymentMerchantPayoutReaderInterface.php @@ -38,9 +38,20 @@ public function getSalesPaymentMerchantPayoutCollectionByMerchantAndOrderReferen /** * @param \Generated\Shared\Transfer\SalesPaymentMerchantPayoutCollectionTransfer $salesPaymentMerchantPayoutCollectionTransfer * - * @return array> + * @return array */ - public function getSalesPaymentMerchantPayoutTransferItemReferencesMapIndexedByTransferId( + public function getSalesPaymentMerchantPayoutTransferTransferIdMapIndexedByItemReference( SalesPaymentMerchantPayoutCollectionTransfer $salesPaymentMerchantPayoutCollectionTransfer ): array; + + /** + * @param string $orderReference + * @param list $itemReferences + * + * @return array + */ + public function getSalesPaymentMerchantPayoutMapByItemReferences( + string $orderReference, + array $itemReferences + ): array; } diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantBusinessFactory.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantBusinessFactory.php index cb1873a..a5399d4 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantBusinessFactory.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantBusinessFactory.php @@ -8,8 +8,8 @@ namespace Spryker\Zed\SalesPaymentMerchant\Business; use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; -use Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpander; -use Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpanderInterface; +use Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpander; +use Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpanderInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Calculator\MerchantPayoutAmountCalculatorFallback; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Calculator\MerchantPayoutCalculator; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Calculator\MerchantPayoutCalculatorInterface; @@ -22,6 +22,9 @@ use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Refund\Checker\PaymentMethodPayoutReverseCheckerInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Refund\MerchantPayoutReverse; use Spryker\Zed\SalesPaymentMerchant\Business\Merchant\Refund\MerchantPayoutReverseInterface; +use Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReader; +use Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface; +use Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderRefundExpenseReader; use Spryker\Zed\SalesPaymentMerchant\Business\Reader\PaymentMethodReader; use Spryker\Zed\SalesPaymentMerchant\Business\Reader\PaymentMethodReaderInterface; use Spryker\Zed\SalesPaymentMerchant\Business\Reader\SalesPaymentMerchantPayoutReader; @@ -57,7 +60,9 @@ public function createMerchantPayout(): MerchantPayoutInterface $this->createTransferEndpointReader(), $this->createTransferRequestSender(), $this->getEntityManager(), - $this->createOrderItemExpander(), + $this->createPaymentTransmissionItemExpander(), + $this->createOrderExpenseReader(), + $this->getConfig(), ); } @@ -71,7 +76,9 @@ public function createMerchantPaymentReverse(): MerchantPayoutReverseInterface $this->createTransferEndpointReader(), $this->createTransferRequestSender(), $this->getEntityManager(), - $this->createOrderItemExpander(), + $this->createPaymentTransmissionItemExpander(), + $this->createOrderRefundExpenseReader(), + $this->getConfig(), ); } @@ -144,11 +151,11 @@ public function createTransferRequestSender(): TransferRequestSenderInterface } /** - * @return \Spryker\Zed\SalesPaymentMerchant\Business\Expander\OrderItemExpanderInterface + * @return \Spryker\Zed\SalesPaymentMerchant\Business\Expander\PaymentTransmissionItemExpanderInterface */ - public function createOrderItemExpander(): OrderItemExpanderInterface + public function createPaymentTransmissionItemExpander(): PaymentTransmissionItemExpanderInterface { - return new OrderItemExpander( + return new PaymentTransmissionItemExpander( $this->createSalesPaymentMerchantPayoutReader(), ); } @@ -191,6 +198,22 @@ public function createPaymentMethodPayoutReverseChecker(): PaymentMethodPayoutRe ); } + /** + * @return \Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface + */ + public function createOrderExpenseReader(): OrderExpenseReaderInterface + { + return new OrderExpenseReader($this->getConfig(), $this->createSalesPaymentMerchantPayoutReader()); + } + + /** + * @return \Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface + */ + public function createOrderRefundExpenseReader(): OrderExpenseReaderInterface + { + return new OrderRefundExpenseReader($this->getConfig()); + } + /** * @return \Spryker\Zed\SalesPaymentMerchant\Dependency\Facade\SalesPaymentMerchantToKernelAppFacadeInterface */ diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantFacadeInterface.php b/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantFacadeInterface.php index 42b40a9..f9cf88c 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantFacadeInterface.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Business/SalesPaymentMerchantFacadeInterface.php @@ -47,6 +47,10 @@ public function isPayoutSupportedForPaymentMethodUsedForOrder( * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - Checks if the order expenses has been already transferred for the merchant order, in case of yes, skips the transfer. * - Sends the transfer request to the PSP App. * - Saves the transfer response to the persistence. * @@ -91,10 +95,15 @@ public function isPayoutReversalSupportedForPaymentMethodUsedForOrder( * - Requires the `ExpenseTransfer.merchantReference` property to be set. * - Requires the `ExpenseTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.uuid` property to be set. - * - Requires the `ExpenseTransfer.sumPriceToPayAggregation` property to be set. + * - Requires the `ExpenseTransfer.refundableAmount` property to be set. + * - Requires the `ExpenseTransfer.canceledAmount` property to be set in case `ExpenseTransfer.refundableAmount` is not set. * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout reverse amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - The order expenses are not transferred until at least one order item is in the refused state {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getItemRefusedStates()}. * - Sends the transfer reverse request to the PSP App. * - Saves the transfer response to the persistence. * diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByItemPlugin.php b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByItemPlugin.php index c780a17..555f617 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByItemPlugin.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByItemPlugin.php @@ -28,9 +28,9 @@ class MerchantPayoutCommandByItemPlugin extends AbstractPlugin implements Comman * - Sends a synchronous request to the PSP App to perform money transfers to merchants. * - The following properties are required in case of merchant item: * - Requires the `ItemTransfer.merchantReference` property to be set. - * - Requires the `OrderTransfer.orderReference` property to be set. * - Requires the `ItemTransfer.orderItemReference` property to be set. * - Requires the `ItemTransfer.sumPriceToPayAggregation` property to be set. + * - Requires the `OrderTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.merchantReference` property to be set. * - Requires the `ExpenseTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.uuid` property to be set. @@ -38,8 +38,12 @@ class MerchantPayoutCommandByItemPlugin extends AbstractPlugin implements Comman * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - Checks if the order expenses has been already transferred for the merchant order, in case of yes, skips the transfer. * - Sends the transfer request to the PSP App. - * - Saves the transfer response to persistence. + * - Saves the transfer response to the persistence. * * @api * diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByOrderPlugin.php b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByOrderPlugin.php index 5249c26..60f36c2 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByOrderPlugin.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandByOrderPlugin.php @@ -24,9 +24,9 @@ class MerchantPayoutCommandByOrderPlugin extends AbstractPlugin implements Comma * - Sends a synchronous request to the PSP App to perform money transfers to merchants. * - The following properties are required in case of merchant item: * - Requires the `ItemTransfer.merchantReference` property to be set. - * - Requires the `OrderTransfer.orderReference` property to be set. * - Requires the `ItemTransfer.orderItemReference` property to be set. * - Requires the `ItemTransfer.sumPriceToPayAggregation` property to be set. + * - Requires the `OrderTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.merchantReference` property to be set. * - Requires the `ExpenseTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.uuid` property to be set. @@ -34,8 +34,12 @@ class MerchantPayoutCommandByOrderPlugin extends AbstractPlugin implements Comma * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - Checks if the order expenses has been already transferred for the merchant order, in case of yes, skips the transfer. * - Sends the transfer request to the PSP App. - * - Saves the transfer response to persistence. + * - Saves the transfer response to the persistence. * * @api * diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByItemPlugin.php b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByItemPlugin.php index a0707a7..bb5246f 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByItemPlugin.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByItemPlugin.php @@ -35,10 +35,15 @@ class MerchantPayoutReverseCommandByItemPlugin extends AbstractPlugin implements * - Requires the `ExpenseTransfer.merchantReference` property to be set. * - Requires the `ExpenseTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.uuid` property to be set. - * - Requires the `ExpenseTransfer.sumPriceToPayAggregation` property to be set. + * - Requires the `ExpenseTransfer.refundableAmount` property to be set. + * - Requires the `ExpenseTransfer.canceledAmount` property to be set in case `ExpenseTransfer.refundableAmount` is not set. * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout reverse amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - The order expenses are not transferred until at least one order item is in the refused state {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getItemRefusedStates()}. * - Sends the transfer reverse request to the PSP App. * - Saves the transfer response to the persistence. * diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByOrderPlugin.php b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByOrderPlugin.php index 55bec77..0801856 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByOrderPlugin.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutReverseCommandByOrderPlugin.php @@ -31,10 +31,15 @@ class MerchantPayoutReverseCommandByOrderPlugin extends AbstractPlugin implement * - Requires the `ExpenseTransfer.merchantReference` property to be set. * - Requires the `ExpenseTransfer.orderReference` property to be set. * - Requires the `ExpenseTransfer.uuid` property to be set. - * - Requires the `ExpenseTransfer.sumPriceToPayAggregation` property to be set. + * - Requires the `ExpenseTransfer.refundableAmount` property to be set. + * - Requires the `ExpenseTransfer.canceledAmount` property to be set in case `ExpenseTransfer.refundableAmount` is not set. * - If the transfer endpoint URL is not found, returns without performing the transfer. * - Fetches the order items and expenses for the transfer. * - Calculates the payout reverse amount using {@link \Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface::calculatePayoutAmount} if it's set. + * - Prepares the order expenses to be transferred if {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::isOrderExpenseIncludedInPaymentProcess()} is set. + * - Otherwise, the order expenses are not transferred. + * - Uses the following configuration to filter out the order expenses for store by type {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getExcludedExpenseTypesForStore()}. + * - The order expenses are not transferred until at least one order item is in the refused state {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getItemRefusedStates()}. * - Sends the transfer reverse request to the PSP App. * - Saves the transfer response to the persistence. * diff --git a/src/Spryker/Zed/SalesPaymentMerchant/Persistence/SalesPaymentMerchantRepository.php b/src/Spryker/Zed/SalesPaymentMerchant/Persistence/SalesPaymentMerchantRepository.php index abf54b9..67f8771 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/Persistence/SalesPaymentMerchantRepository.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/Persistence/SalesPaymentMerchantRepository.php @@ -101,6 +101,12 @@ protected function applySalesPaymentMerchantPayoutFilters( ); } + if ($salesPaymentMerchantPayoutConditionsTransfer->getItemReferences() !== []) { + $salesPaymentMerchantPayoutQuery->filterByItemReferences_In( + $salesPaymentMerchantPayoutConditionsTransfer->getItemReferences(), + ); + } + // Only fetch entities that have a transferId and are not failed. $salesPaymentMerchantPayoutQuery->filterByTransferId(null, Criteria::ISNOTNULL); diff --git a/src/Spryker/Zed/SalesPaymentMerchant/SalesPaymentMerchantConfig.php b/src/Spryker/Zed/SalesPaymentMerchant/SalesPaymentMerchantConfig.php index 5a4d1e1..05b7fe1 100644 --- a/src/Spryker/Zed/SalesPaymentMerchant/SalesPaymentMerchantConfig.php +++ b/src/Spryker/Zed/SalesPaymentMerchant/SalesPaymentMerchantConfig.php @@ -12,95 +12,91 @@ class SalesPaymentMerchantConfig extends AbstractBundleConfig { /** + * Specification: + * - Represents the type for order items in payment transmission. + * + * @api + * * @var string */ - public const ITEM_REFERENCE_SEPARATOR = ','; + public const PAYMENT_TRANSMISSION_ITEM_TYPE_ORDER_ITEM = 'order-item'; /** + * Specification: + * - Represents the type for order expenses in payment transmission. + * + * @api + * * @var string */ - protected const OMS_STATE_PAYMENT_CAPTURE_PENDING = 'payment capture pending'; + public const PAYMENT_TRANSMISSION_ITEM_TYPE_ORDER_EXPENSE = 'order-expense'; /** * @var string */ - protected const OMS_STATE_PAYMENT_REFUND_PENDING = 'payment refund pending'; + public const ITEM_REFERENCE_SEPARATOR = ','; /** - * @var string + * @var array> */ - protected const OMS_STATE_PAYMENT_CAPTURED = 'payment captured'; + protected const EXCLUDED_EXPENSE_TYPES_FOR_STORE = []; /** * @var string */ - protected const OMS_STATE_PAYMENT_REFUNDED = 'payment refunded'; + protected const OMS_STATE_PAYMENT_CANCELED = 'canceled'; /** * @var string */ - protected const OMS_STATE_PAYMENT_CANCELED = 'canceled'; + protected const OMS_STATE_PAYMENT_CLOSED = 'closed'; /** - * @api - * - * @return array + * @var bool */ - public function getPaymentCaptureRequestBlockingStates(): array - { - return [ - static::OMS_STATE_PAYMENT_CAPTURE_PENDING, - static::OMS_STATE_PAYMENT_REFUND_PENDING, - ]; - } + protected const ORDER_EXPENSE_INCLUDED_IN_PAYMENT_PROCESS = false; /** - * @api - * - * @deprecated Use {@link \Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantConfig::getCapturePaymentStates()} instead. + * Specification: + * - Provides a list of OMS states that are considered as refused payment states. * - * @return array - */ - public function getPaymentConfirmationRequestedStates(): array - { - return []; - } - - /** * @api * * @return array */ - public function getCapturePaymentStates(): array + public function getItemRefusedStates(): array { return [ - static::OMS_STATE_PAYMENT_CAPTURED, + static::OMS_STATE_PAYMENT_CANCELED, + static::OMS_STATE_PAYMENT_CLOSED, ]; } /** + * Specification: + * - Provides a list of expense types to be excluded from the transfer process for the given store. + * * @api * - * @return array + * @param string $storeName + * + * @return list */ - public function getPaymentRefundRequestBlockingStates(): array + public function getExcludedExpenseTypesForStore(string $storeName): array { - return [ - static::OMS_STATE_PAYMENT_CAPTURE_PENDING, - static::OMS_STATE_PAYMENT_REFUND_PENDING, - ]; + return static::EXCLUDED_EXPENSE_TYPES_FOR_STORE[$storeName] ?? []; } /** + * Specification: + * - Determines whether order expenses should be included in the transfer process. + * * @api * - * @return array + * @return bool */ - public function getItemRefusedStates(): array + public function isOrderExpenseIncludedInPaymentProcess(): bool { - return [ - static::OMS_STATE_PAYMENT_REFUNDED, - static::OMS_STATE_PAYMENT_CANCELED, - ]; + return static::ORDER_EXPENSE_INCLUDED_IN_PAYMENT_PROCESS; } } diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandPluginTest.php b/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandPluginTest.php index 4e538bd..9a1556e 100644 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandPluginTest.php +++ b/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantPayoutCommandPluginTest.php @@ -8,16 +8,19 @@ namespace SprykerTest\Zed\SalesPaymentMerchant\Communication\Plugin\Oms\Command; use Codeception\Test\Unit; -use Generated\Shared\Transfer\EndpointTransfer; +use Generated\Shared\Transfer\AcpHttpResponseTransfer; +use Generated\Shared\Transfer\ExpenseTransfer; use Generated\Shared\Transfer\MerchantTransfer; -use Generated\Shared\Transfer\PaymentMethodAppConfigurationTransfer; use Generated\Shared\Transfer\PaymentMethodTransfer; use Generated\Shared\Transfer\PaymentProviderTransfer; use Ramsey\Uuid\Uuid; use Spryker\Shared\Kernel\Container\GlobalContainer; use Spryker\Zed\Kernel\Container; +use Spryker\Zed\KernelApp\Business\KernelAppFacadeInterface; use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; +use Spryker\Zed\SalesPaymentMerchant\Business\Reader\OrderExpenseReaderInterface; use Spryker\Zed\SalesPaymentMerchant\Communication\Plugin\Oms\Command\MerchantPayoutCommandByOrderPlugin; +use Spryker\Zed\SalesPaymentMerchant\Dependency\Facade\SalesPaymentMerchantToKernelAppFacadeBridge; use Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantDependencyProvider; use Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface; use SprykerTest\Zed\SalesPaymentMerchant\SalesPaymentMerchantCommunicationTester; @@ -37,28 +40,51 @@ */ class MerchantPayoutCommandPluginTest extends Unit { + /** + * @uses \Spryker\Shared\Shipment\ShipmentConfig::SHIPMENT_EXPENSE_TYPE + * + * @var string + */ + protected const SHIPMENT_EXPENSE_TYPE = 'SHIPMENT_EXPENSE_TYPE'; + /** * @var \SprykerTest\Zed\SalesPaymentMerchant\SalesPaymentMerchantCommunicationTester $tester */ protected SalesPaymentMerchantCommunicationTester $tester; /** - * Test ensures that when a payment method is not configured to transfer payments, the command is skipped without a failure. - * + * @var string + */ + protected string $merchantReference; + + /** + * @var string + */ + protected string $orderReference; + + /** + * @var \Generated\Shared\Transfer\PaymentProviderTransfer + */ + protected PaymentProviderTransfer $paymentProviderTransfer; + + /** * @return void */ - public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExecutedAndThePaymentMethodDoesNotHaveTransferOfPaymentsEnabledTheCommandIsSkipped(): void + protected function setUp(): void { - // Arrange - $merchantReference = Uuid::uuid4()->toString(); - $orderReference = Uuid::uuid4()->toString(); + parent::setUp(); + + $this->merchantReference = Uuid::uuid4()->toString(); + $this->orderReference = Uuid::uuid4()->toString(); $globalContainer = new GlobalContainer(); $globalContainer->setContainer(new Container([ 'locale' => 'de_DE', ])); - $paymentProviderTransfer = $this->tester->havePaymentProvider([ + $this->tester->mockHydrateOrderPluginsInSalesModule(); + + $this->paymentProviderTransfer = $this->tester->havePaymentProvider([ PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', PaymentProviderTransfer::NAME => 'foo', ]); @@ -66,17 +92,24 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe $this->tester->havePaymentMethod([ PaymentMethodTransfer::NAME => 'Foo', PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), + PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $this->paymentProviderTransfer->getIdPaymentProvider(), ]); - $this->tester->mockHydrateOrderPluginsInSalesModule(); - $this->tester->haveMerchant([ - MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, + MerchantTransfer::MERCHANT_REFERENCE => $this->merchantReference, ]); + } - $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); + /** + * Test ensures that when a payment method is not configured to transfer payments, the command is skipped without a failure. + * + * @return void + */ + public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExecutedAndThePaymentMethodDoesNotHaveTransferOfPaymentsEnabledTheCommandIsSkipped(): void + { + // Arrange + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); // Act @@ -93,47 +126,14 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExecutedAndTheExternalPSPReturnsASuccessfulResponseThenAllOrderItemsOfThisMerchantArePersisted(): void { // Arrange - $merchantReference = Uuid::uuid4()->toString(); - $orderReference = Uuid::uuid4()->toString(); - - $globalContainer = new GlobalContainer(); - $globalContainer->setContainer(new Container([ - 'locale' => 'de_DE', - ])); - - $paymentProviderTransfer = $this->tester->havePaymentProvider([ - PaymentProviderTransfer::NAME => 'Foo', - PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', - ]); - - $this->tester->havePaymentMethod([ - PaymentMethodTransfer::NAME => 'Foo', - PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), - PaymentMethodTransfer::PAYMENT_METHOD_APP_CONFIGURATION => [ - PaymentMethodAppConfigurationTransfer::BASE_URL => 'http://localhost:8080', - PaymentMethodAppConfigurationTransfer::ENDPOINTS => [ - [ - EndpointTransfer::NAME => 'transfer', - EndpointTransfer::PATH => '/payouts', - ], - ], - ], - ]); - - $this->tester->mockHydrateOrderPluginsInSalesModule(); - - $this->tester->haveMerchant([ - MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, - ]); - - $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); $this->tester->mockExpectedResponseFromApp( - $merchantReference, - $orderReference, + $this->merchantReference, + $this->orderReference, [['itemReference' => $salesOrderItemWithMerchant->getOrderItemReference()]], '900', ); @@ -143,7 +143,7 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); // Assert - $this->tester->assertSalesPaymentMerchantPayoutEntity($merchantReference, $orderReference, [$salesOrderItemWithMerchant]); + $this->tester->assertSalesPaymentMerchantPayoutEntity($this->merchantReference, $this->orderReference, [$salesOrderItemWithMerchant->getOrderItemReference()]); } /** @@ -152,46 +152,22 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe public function testAmountCalculatorPluginIsCalledWhenPluggedIn(): void { // Arrange - $merchantReference = Uuid::uuid4()->toString(); - $orderReference = Uuid::uuid4()->toString(); - - $paymentProviderTransfer = $this->tester->havePaymentProvider([ - PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', - PaymentProviderTransfer::NAME => 'foo', - ]); - - $this->tester->havePaymentMethod([ - PaymentMethodTransfer::NAME => 'Foo', - PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), - PaymentMethodTransfer::PAYMENT_METHOD_APP_CONFIGURATION => [ - PaymentMethodAppConfigurationTransfer::BASE_URL => 'http://localhost:8080', - PaymentMethodAppConfigurationTransfer::ENDPOINTS => [ - [ - EndpointTransfer::NAME => 'transfer', - EndpointTransfer::PATH => '/payouts', - ], - ], - ], - ]); - - $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); - $this->tester->haveMerchant([MerchantTransfer::MERCHANT_REFERENCE => $merchantReference]); $this->tester->mockExpectedResponseFromApp( - $merchantReference, - $orderReference, + $this->merchantReference, + $this->orderReference, [['itemReference' => $salesOrderItemWithMerchant->getOrderItemReference()]], '900', ); - //Expect + // Expect $amountCalculatorPluginMock = $this->createMock(MerchantPayoutCalculatorPluginInterface::class); $amountCalculatorPluginMock->expects($this->once()) - ->method('calculatePayoutAmount') - ->willReturn(100); + ->method('calculatePayoutAmount'); $this->tester->setDependency( SalesPaymentMerchantDependencyProvider::PLUGIN_MERCHANT_PAYOUT_AMOUNT_CALCULATOR, @@ -202,4 +178,214 @@ public function testAmountCalculatorPluginIsCalledWhenPluggedIn(): void $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); } + + /** + * @return void + */ + public function testOrderExpenseAreNotSentWhenOrderExpenseIncludedInPaymentProcessIsDisabled(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', false); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); + $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); + + $this->tester->mockExpectedResponseFromApp( + $this->merchantReference, + $this->orderReference, + [ + ['itemReference' => $salesOrderItemWithMerchant->getOrderItemReference()], + ], + '900', + ); + + // Expect + $orderExpenseReaderMock = $this->createMock(OrderExpenseReaderInterface::class); + $orderExpenseReaderMock->expects($this->never())->method('getOrderExpensesForTransfer'); + $this->tester->mockFactoryMethod('createOrderExpenseReader', $orderExpenseReaderMock); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + } + + /** + * @return void + */ + public function testOrderExpensesAreSentWhenOrderExpenseIncludedInPaymentProcessIsEnabled(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); + + $shipmentExpenseTransfer = $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $this->merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + $this->tester->mockExpectedResponseFromApp( + $this->merchantReference, + $this->orderReference, + [ + ['itemReference' => $salesOrderItemWithMerchant->getOrderItemReference()], + ['itemReference' => $shipmentExpenseTransfer->getUuid()], + ], + '900', + ); + + $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + + // Assert + $this->tester->assertSalesPaymentMerchantPayoutEntity($this->merchantReference, $this->orderReference, [$shipmentExpenseTransfer->getUuid()]); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentWhenAlreadySentForThisOrder(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); + + $shipmentExpenseTransfer = $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $this->merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted([ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $this->merchantReference, + 'order_reference' => $this->orderReference, + 'item_references' => $shipmentExpenseTransfer->getUuid(), + 'is_successful' => true, + 'amount' => 900, + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($salesOrderEntity->getItems()->getArrayCopy(), $salesOrderEntity, new ReadOnlyArrayObject([])); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentWhenTheOrderItemOfAnotherMerchantIsSentForMarketplaceOrder(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $merchantReferenceB = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceB, + ]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReferenceB); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReferenceB, $this->orderReference); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $this->merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($salesOrderEntity->getItems()->getArrayCopy(), $salesOrderEntity, new ReadOnlyArrayObject([])); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentWhenTheyAreNotRelatedToTheMerchantOrder(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $merchantReferenceB = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceB, + ]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReferenceB); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReferenceB, $this->orderReference); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => 'some-type', + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($salesOrderEntity->getItems()->getArrayCopy(), $salesOrderEntity, new ReadOnlyArrayObject([])); + } + + /** + * @return void + */ + public function testOrderExpensesWithShipmentTypeAreNotSentWhenTheyAreExcludedForTheGivenStore(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $this->tester->mockConfigMethod('getExcludedExpenseTypesForStore', ['DE' => static::SHIPMENT_EXPENSE_TYPE]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($this->merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $this->merchantReference, $this->orderReference); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $this->merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $merchantPayoutCommandPlugin = new MerchantPayoutCommandByOrderPlugin(); + $merchantPayoutCommandPlugin->setFacade($this->tester->getFacade()); + $merchantPayoutCommandPlugin->run($salesOrderEntity->getItems()->getArrayCopy(), $salesOrderEntity, new ReadOnlyArrayObject([])); + } + + /** + * @return void + */ + protected function mockKernelAppFacadeMakeRequestOnce(): void + { + $transferRequestSenderMock = $this->createMock(KernelAppFacadeInterface::class); + + $transferRequestSenderMock->expects($this->once())->method('makeRequest')->willReturn( + (new AcpHttpResponseTransfer())->setContent(json_encode(['transfers' => []])), + ); + + $this->tester->setDependency(SalesPaymentMerchantDependencyProvider::FACADE_KERNEL_APP, new SalesPaymentMerchantToKernelAppFacadeBridge($transferRequestSenderMock)); + } } diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantRefundCommandPluginTest.php b/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantRefundCommandPluginTest.php index 26e176b..2236486 100644 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantRefundCommandPluginTest.php +++ b/tests/SprykerTest/Zed/SalesPaymentMerchant/Communication/Plugin/Oms/Command/MerchantRefundCommandPluginTest.php @@ -8,16 +8,19 @@ namespace SprykerTest\Zed\SalesPaymentMerchant\Communication\Plugin\Oms\Command; use Codeception\Test\Unit; -use Generated\Shared\Transfer\EndpointTransfer; +use Generated\Shared\Transfer\AcpHttpResponseTransfer; +use Generated\Shared\Transfer\ExpenseTransfer; use Generated\Shared\Transfer\MerchantTransfer; -use Generated\Shared\Transfer\PaymentMethodAppConfigurationTransfer; use Generated\Shared\Transfer\PaymentMethodTransfer; use Generated\Shared\Transfer\PaymentProviderTransfer; +use Orm\Zed\Sales\Persistence\SpySalesOrder; use Ramsey\Uuid\Uuid; use Spryker\Shared\Kernel\Container\GlobalContainer; use Spryker\Zed\Kernel\Container; +use Spryker\Zed\KernelApp\Business\KernelAppFacadeInterface; use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; use Spryker\Zed\SalesPaymentMerchant\Communication\Plugin\Oms\Command\MerchantPayoutReverseCommandByOrderPlugin; +use Spryker\Zed\SalesPaymentMerchant\Dependency\Facade\SalesPaymentMerchantToKernelAppFacadeBridge; use Spryker\Zed\SalesPaymentMerchant\SalesPaymentMerchantDependencyProvider; use Spryker\Zed\SalesPaymentMerchantExtension\Communication\Dependency\Plugin\MerchantPayoutCalculatorPluginInterface; use SprykerTest\Zed\SalesPaymentMerchant\SalesPaymentMerchantCommunicationTester; @@ -37,6 +40,18 @@ */ class MerchantRefundCommandPluginTest extends Unit { + /** + * @uses \Spryker\Shared\Shipment\ShipmentConfig::SHIPMENT_EXPENSE_TYPE + * + * @var string + */ + protected const SHIPMENT_EXPENSE_TYPE = 'SHIPMENT_EXPENSE_TYPE'; + + /** + * @var string + */ + protected const OMS_STATE_PAYMENT_NEW = 'new'; + /** * @var \SprykerTest\Zed\SalesPaymentMerchant\SalesPaymentMerchantCommunicationTester $tester */ @@ -83,8 +98,7 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe $salesOrderEntity = $this->tester->mockSalesOrderEntity($orderItems, $merchantReference, $orderReference); // Act - $merchantPayoutCommandPlugin = new MerchantPayoutReverseCommandByOrderPlugin(); - $response = $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + $response = $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); // Assert $this->tester->assertIsArray($response); @@ -105,37 +119,20 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe 'locale' => 'de_DE', ])); - $paymentProviderTransfer = $this->tester->havePaymentProvider([ - PaymentProviderTransfer::NAME => 'Foo', - PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', - ]); - - $this->tester->havePaymentMethod([ - PaymentMethodTransfer::NAME => 'bar', - PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), - PaymentMethodTransfer::PAYMENT_METHOD_APP_CONFIGURATION => [ - PaymentMethodAppConfigurationTransfer::BASE_URL => 'http://localhost:8080', - PaymentMethodAppConfigurationTransfer::ENDPOINTS => [ - [ - EndpointTransfer::NAME => 'transfer', - EndpointTransfer::PATH => '/reverse-payouts', - ], - ], - ], - ]); - + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); $this->tester->mockHydrateOrderPluginsInSalesModule(); - $this->tester->haveMerchant([ MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, ]); $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); - $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); + $salesOrderEntity = $this->tester->mockSalesOrderEntity( + [$salesOrderItemWithMerchant], + $merchantReference, + $orderReference, + ); - $salesPaymentMerchantPayoutEntity = $this->tester->haveSalesPaymentMerchantPayoutPersisted([ + $this->tester->haveSalesPaymentMerchantPayoutPersisted([ 'transfer_id' => $transferId, 'merchant_reference' => $merchantReference, 'order_reference' => $orderReference, @@ -144,8 +141,6 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe 'amount' => 900, ]); - $salesOrderEntity->addSpySalesPaymentMerchantPayout($salesPaymentMerchantPayoutEntity); - $this->tester->mockExpectedResponseFromApp( $merchantReference, $orderReference, @@ -163,11 +158,10 @@ public function testGivenAnOrderWithOneOrderItemFromAMerchantWhenTheCommandIsExe ]); // Act - $merchantPayoutCommandPlugin = new MerchantPayoutReverseCommandByOrderPlugin(); - $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); // Assert - $this->tester->assertSalesPaymentMerchantRefundEntity($merchantReference, $orderReference, [$salesOrderItemWithMerchant]); + $this->tester->assertSalesPaymentMerchantRefundEntity($merchantReference, $orderReference, [$salesOrderItemWithMerchant->getOrderItemReference()]); } /** @@ -186,26 +180,7 @@ public function testGivenAnOrderWithTwoOrderItemsFromDifferentMerchantsWhenTheCo 'locale' => 'de_DE', ])); - $paymentProviderTransfer = $this->tester->havePaymentProvider([ - PaymentProviderTransfer::NAME => 'Foo', - PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', - ]); - - $this->tester->havePaymentMethod([ - PaymentMethodTransfer::NAME => 'bar', - PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), - PaymentMethodTransfer::PAYMENT_METHOD_APP_CONFIGURATION => [ - PaymentMethodAppConfigurationTransfer::BASE_URL => 'http://localhost:8080', - PaymentMethodAppConfigurationTransfer::ENDPOINTS => [ - [ - EndpointTransfer::NAME => 'transfer', - EndpointTransfer::PATH => '/reverse-payouts', - ], - ], - ], - ]); - + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); $this->tester->mockHydrateOrderPluginsInSalesModule(); $this->tester->haveMerchant([ @@ -219,10 +194,12 @@ public function testGivenAnOrderWithTwoOrderItemsFromDifferentMerchantsWhenTheCo $salesOrderItemWithMerchantOne = $this->tester->createSalesOrderItemEntity($merchantReferenceOne); $salesOrderItemWithMerchantTwo = $this->tester->createSalesOrderItemEntity($merchantReferenceTwo); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchantOne, $salesOrderItemWithMerchantTwo], $merchantReferenceOne, $orderReference); - $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([ + $salesOrderItemWithMerchantOne, + $salesOrderItemWithMerchantTwo, + ], $merchantReferenceOne, $orderReference); - $salesPaymentMerchantPayoutEntityErrored = $this->tester->haveSalesPaymentMerchantPayoutPersisted([ + $this->tester->haveSalesPaymentMerchantPayoutPersisted([ 'transfer_id' => null, // A failed response does not have a transfer id 'order_reference' => $orderReference, 'item_references' => '', @@ -230,7 +207,7 @@ public function testGivenAnOrderWithTwoOrderItemsFromDifferentMerchantsWhenTheCo 'amount' => 0, ]); - $salesPaymentMerchantPayoutEntity = $this->tester->haveSalesPaymentMerchantPayoutPersisted([ + $this->tester->haveSalesPaymentMerchantPayoutPersisted([ 'transfer_id' => $transferId, 'merchant_reference' => $merchantReferenceOne, 'order_reference' => $orderReference, @@ -239,9 +216,6 @@ public function testGivenAnOrderWithTwoOrderItemsFromDifferentMerchantsWhenTheCo 'amount' => 900, ]); - $salesOrderEntity->addSpySalesPaymentMerchantPayout($salesPaymentMerchantPayoutEntity); - $salesOrderEntity->addSpySalesPaymentMerchantPayout($salesPaymentMerchantPayoutEntityErrored); - $this->tester->mockExpectedResponseFromApp( $merchantReferenceOne, $orderReference, @@ -250,11 +224,10 @@ public function testGivenAnOrderWithTwoOrderItemsFromDifferentMerchantsWhenTheCo ); // Act - $merchantPayoutCommandPlugin = new MerchantPayoutReverseCommandByOrderPlugin(); - $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); // Assert - $this->tester->assertSalesPaymentMerchantRefundEntity($merchantReferenceOne, $orderReference, [$salesOrderItemWithMerchantOne]); + $this->tester->assertSalesPaymentMerchantRefundEntity($merchantReferenceOne, $orderReference, [$salesOrderItemWithMerchantOne->getOrderItemReference()]); } /** @@ -267,31 +240,15 @@ public function testMerchantPayoutReverseAmountCalculatorPluginIsCalled(): void $orderReference = Uuid::uuid4()->toString(); $transferId = Uuid::uuid4()->toString(); - $paymentProviderTransfer = $this->tester->havePaymentProvider([ - PaymentProviderTransfer::NAME => 'Foo', - PaymentProviderTransfer::PAYMENT_PROVIDER_KEY => 'foo', - ]); - - $this->tester->havePaymentMethod([ - PaymentMethodTransfer::NAME => 'bar', - PaymentMethodTransfer::PAYMENT_METHOD_KEY => 'foo-bar', - PaymentMethodTransfer::ID_PAYMENT_PROVIDER => $paymentProviderTransfer->getIdPaymentProvider(), - PaymentMethodTransfer::PAYMENT_METHOD_APP_CONFIGURATION => [ - PaymentMethodAppConfigurationTransfer::BASE_URL => 'http://localhost:8080', - PaymentMethodAppConfigurationTransfer::ENDPOINTS => [ - [ - EndpointTransfer::NAME => 'transfer', - EndpointTransfer::PATH => '/payouts', - ], - ], - ], - ]); - + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); $this->tester->haveMerchant([MerchantTransfer::MERCHANT_REFERENCE => $merchantReference]); $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); - $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); - $orderItems = $salesOrderEntity->getItems()->getArrayCopy(); + $salesOrderEntity = $this->tester->mockSalesOrderEntity( + [$salesOrderItemWithMerchant], + $merchantReference, + $orderReference, + ); $salesPaymentMerchantPayoutEntity = $this->tester->haveSalesPaymentMerchantPayoutPersisted( [ @@ -324,7 +281,325 @@ public function testMerchantPayoutReverseAmountCalculatorPluginIsCalled(): void ); // Act - $merchantPayoutCommandPlugin = new MerchantPayoutReverseCommandByOrderPlugin(); - $merchantPayoutCommandPlugin->run($orderItems, $salesOrderEntity, new ReadOnlyArrayObject([])); + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + public function testOrderExpensesAreSentToReverseWhenOrderExpenseIncludedInPaymentProcess(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $this->tester->mockConfigMethod('getItemRefusedStates', [static::OMS_STATE_PAYMENT_NEW]); + + $orderReference = Uuid::uuid4()->toString(); + $merchantReferenceA = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceA, + ]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReferenceA); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReferenceA, $orderReference); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReferenceA, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $expenseTransfer = $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $merchantReferenceA, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReferenceA, + 'order_reference' => $orderReference, + 'item_references' => $expenseTransfer->getUuid(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->mockExpectedResponseFromApp( + $merchantReferenceA, + $orderReference, + [ + ['itemReference' => $salesOrderItemWithMerchant->getOrderItemReference()], + ['itemReference' => $expenseTransfer->getUuid()], + ], + '-900', + ); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + + // Assert + $this->tester->assertSalesPaymentMerchantRefundEntity($merchantReferenceA, $orderReference, [$salesOrderItemWithMerchant->getOrderItemReference(), $expenseTransfer->getUuid()]); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentToReverseWhenOrderItemOfAnotherMerchantIsSentForMarketplaceOrder(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $this->tester->mockConfigMethod('getItemRefusedStates', [static::OMS_STATE_PAYMENT_NEW]); + + $orderReference = Uuid::uuid4()->toString(); + $merchantReferenceA = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceA, + ]); + $merchantReferenceB = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceB, + ]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReferenceA); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReferenceA, $orderReference); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReferenceA, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $merchantReferenceB, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentToReverseWhenTheyAreNotRelatedToTheMerchantOrder(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $this->tester->mockConfigMethod('getItemRefusedStates', [static::OMS_STATE_PAYMENT_NEW]); + + $orderReference = Uuid::uuid4()->toString(); + $merchantReferenceA = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceA, + ]); + $merchantReferenceB = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReferenceB, + ]); + + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReferenceA); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReferenceA, $orderReference); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReferenceA, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + public function testOrderExpensesWithShipmentTypeAreNotSentWhenTheyAreExcludedForTheGivenStore(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + $this->tester->mockConfigMethod('getExcludedExpenseTypesForStore', ['DE' => static::SHIPMENT_EXPENSE_TYPE]); + + $merchantReference = Uuid::uuid4()->toString(); + $orderReference = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, + ]); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReference, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentWhenOrderExpenseIncludedInPaymentProcessDisabled(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', false); + + $merchantReference = Uuid::uuid4()->toString(); + $orderReference = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, + ]); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity([$salesOrderItemWithMerchant], $merchantReference, $orderReference); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReference, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + public function testOrderExpensesAreNotSentWhenOrderHasUnRefusedItems(): void + { + // Arrange + $this->tester->havePaymentProviderWithPaymentMethodSupportingPayouts(); + $this->tester->mockConfigMethod('isOrderExpenseIncludedInPaymentProcess', true); + + $merchantReference = Uuid::uuid4()->toString(); + $orderReference = Uuid::uuid4()->toString(); + $this->tester->haveMerchant([ + MerchantTransfer::MERCHANT_REFERENCE => $merchantReference, + ]); + $salesOrderItemWithMerchant = $this->tester->createSalesOrderItemEntity($merchantReference); + $salesOrderEntity = $this->tester->mockSalesOrderEntity( + [$salesOrderItemWithMerchant], + $merchantReference, + $orderReference, + ); + + $this->tester->haveSalesPaymentMerchantPayoutPersisted( + [ + 'transfer_id' => Uuid::uuid4()->toString(), + 'merchant_reference' => $merchantReference, + 'order_reference' => $orderReference, + 'item_references' => $salesOrderItemWithMerchant->getOrderItemReference(), + 'is_successful' => true, + 'amount' => 900, + ], + ); + + $this->tester->haveSalesExpense([ + ExpenseTransfer::TYPE => static::SHIPMENT_EXPENSE_TYPE, + ExpenseTransfer::MERCHANT_REFERENCE => $merchantReference, + ExpenseTransfer::FK_SALES_ORDER => $salesOrderEntity->getIdSalesOrder(), + ]); + + // Expect + $this->mockKernelAppFacadeMakeRequestOnce(); + + // Act + $this->runMerchantPayoutReverseCommandByOrderPlugin($salesOrderEntity); + } + + /** + * @return void + */ + protected function mockKernelAppFacadeMakeRequestOnce(): void + { + $transferRequestSenderMock = $this->createMock(KernelAppFacadeInterface::class); + + $transferRequestSenderMock->expects($this->once())->method('makeRequest')->willReturn( + (new AcpHttpResponseTransfer())->setContent(json_encode(['transfers' => []])), + ); + + $this->tester->setDependency( + SalesPaymentMerchantDependencyProvider::FACADE_KERNEL_APP, + new SalesPaymentMerchantToKernelAppFacadeBridge($transferRequestSenderMock), + ); + } + + /** + * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $salesOrderEntity + * + * @return array + */ + protected function runMerchantPayoutReverseCommandByOrderPlugin(SpySalesOrder $salesOrderEntity): array + { + $merchantPayoutReverseCommandByOrderPlugin = new MerchantPayoutReverseCommandByOrderPlugin(); + $merchantPayoutReverseCommandByOrderPlugin->setFacade($this->tester->getFacade()); + + return $merchantPayoutReverseCommandByOrderPlugin->run( + $salesOrderEntity->getItems()->getArrayCopy(), + $salesOrderEntity, + new ReadOnlyArrayObject([]), + ); } } diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/Helper/SalesPaymentMerchantHelper.php b/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/Helper/SalesPaymentMerchantHelper.php index c7fe35b..3dec3b4 100644 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/Helper/SalesPaymentMerchantHelper.php +++ b/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/Helper/SalesPaymentMerchantHelper.php @@ -91,11 +91,11 @@ public function createSalesOrderEntity(array $seed): SpySalesOrder /** * @param string $merchantReference * @param string $orderReference - * @param array $salesOrderItems + * @param list $salesPaymentPayoutReferences * * @return void */ - public function assertSalesPaymentMerchantPayoutEntity(string $merchantReference, string $orderReference, array $salesOrderItems): void + public function assertSalesPaymentMerchantPayoutEntity(string $merchantReference, string $orderReference, array $salesPaymentPayoutReferences): void { $salesPaymentMerchantPayoutEntity = SpySalesPaymentMerchantPayoutQuery::create() ->filterByMerchantReference($merchantReference) @@ -106,19 +106,19 @@ public function assertSalesPaymentMerchantPayoutEntity(string $merchantReference $itemReferences = explode(',', $salesPaymentMerchantPayoutEntity->getItemReferences()); - foreach ($salesOrderItems as $salesOrderItem) { - $this->assertContains($salesOrderItem->getOrderItemReference(), $itemReferences); + foreach ($salesPaymentPayoutReferences as $salesPaymentPayoutReference) { + $this->assertContains($salesPaymentPayoutReference, $itemReferences); } } /** * @param string $merchantReference * @param string $orderReference - * @param array $salesOrderItems + * @param list $salesPaymentMerchantRefundReferences * * @return void */ - public function assertSalesPaymentMerchantRefundEntity(string $merchantReference, string $orderReference, array $salesOrderItems): void + public function assertSalesPaymentMerchantRefundEntity(string $merchantReference, string $orderReference, array $salesPaymentMerchantRefundReferences): void { $salesPaymentMerchantRefundEntity = SpySalesPaymentMerchantPayoutReversalQuery::create() ->filterByMerchantReference($merchantReference) @@ -129,8 +129,8 @@ public function assertSalesPaymentMerchantRefundEntity(string $merchantReference $itemReferences = explode(',', $salesPaymentMerchantRefundEntity->getItemReferences()); - foreach ($salesOrderItems as $salesOrderItem) { - $this->assertContains($salesOrderItem->getOrderItemReference(), $itemReferences); + foreach ($salesPaymentMerchantRefundReferences as $salesPaymentMerchantRefundReference) { + $this->assertContains($salesPaymentMerchantRefundReference, $itemReferences); } } } diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/SalesPaymentMerchantCommunicationTester.php b/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/SalesPaymentMerchantCommunicationTester.php index df0bef4..b26c33a 100644 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/SalesPaymentMerchantCommunicationTester.php +++ b/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/SalesPaymentMerchantCommunicationTester.php @@ -155,8 +155,12 @@ public function mockSalesOrderEntity( * * @return void */ - public function mockExpectedResponseFromApp(string $merchantReference, string $orderReference, array $orderItemReferences, string $amount): void - { + public function mockExpectedResponseFromApp( + string $merchantReference, + string $orderReference, + array $orderItemReferences, + string $amount + ): void { $string = json_encode([ 'transfers' => [ [ @@ -168,6 +172,7 @@ public function mockExpectedResponseFromApp(string $merchantReference, string $o ], ], ]); + $acpHttpResponseTransfer = new AcpHttpResponseTransfer(); $acpHttpResponseTransfer->setContent($string); diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/_generated/SalesPaymentMerchantCommunicationTesterActions.php b/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/_generated/SalesPaymentMerchantCommunicationTesterActions.php deleted file mode 100644 index eb6a2bf..0000000 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/_support/_generated/SalesPaymentMerchantCommunicationTesterActions.php +++ /dev/null @@ -1,2440 +0,0 @@ -expectThrowable(MyThrowable::class, function() { - * $this->doSomethingBad(); - * }); - * - * $I->expectThrowable(new MyException(), function() { - * $this->doSomethingBad(); - * }); - * ``` - * If you want to check message or throwable code, you can pass them with throwable instance: - * ```php - * expectThrowable(new MyError("Don't do bad things"), function() { - * $this->doSomethingBad(); - * }); - * ``` - * - * @param \Throwable|string $throwable - * @see \Codeception\Module\Asserts::expectThrowable() - */ - public function expectThrowable($throwable, callable $callback): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('expectThrowable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file does not exist. - * @see \Codeception\Module\AbstractAsserts::assertFileNotExists() - */ - public function assertFileNotExists(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is greater than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertGreaterOrEquals() - */ - public function assertGreaterOrEquals($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is empty. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsEmpty() - */ - public function assertIsEmpty($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is smaller than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertLessOrEquals() - */ - public function assertLessOrEquals($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string does not match a given regular expression. - * @see \Codeception\Module\AbstractAsserts::assertNotRegExp() - */ - public function assertNotRegExp(string $pattern, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string matches a given regular expression. - * @see \Codeception\Module\AbstractAsserts::assertRegExp() - */ - public function assertRegExp(string $pattern, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Evaluates a PHPUnit\Framework\Constraint matcher object. - * - * @param mixed $value - * @see \Codeception\Module\AbstractAsserts::assertThatItsNot() - */ - public function assertThatItsNot($value, \PHPUnit\Framework\Constraint\Constraint $constraint, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThatItsNot', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that an array has a specified key. - * - * @param int|string $key - * @param array|\ArrayAccess $array - * @see \Codeception\Module\AbstractAsserts::assertArrayHasKey() - */ - public function assertArrayHasKey($key, $array, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that an array does not have a specified key. - * - * @param int|string $key - * @param array|\ArrayAccess $array - * @see \Codeception\Module\AbstractAsserts::assertArrayNotHasKey() - */ - public function assertArrayNotHasKey($key, $array, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a class has a specified attribute. - * @see \Codeception\Module\AbstractAsserts::assertClassHasAttribute() - */ - public function assertClassHasAttribute(string $attributeName, string $className, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a class has a specified static attribute. - * @see \Codeception\Module\AbstractAsserts::assertClassHasStaticAttribute() - */ - public function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassHasStaticAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a class does not have a specified attribute. - * @see \Codeception\Module\AbstractAsserts::assertClassNotHasAttribute() - */ - public function assertClassNotHasAttribute(string $attributeName, string $className, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a class does not have a specified static attribute. - * @see \Codeception\Module\AbstractAsserts::assertClassNotHasStaticAttribute() - */ - public function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertClassNotHasStaticAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a haystack contains a needle. - * - * @param mixed $needle - * @see \Codeception\Module\AbstractAsserts::assertContains() - */ - public function assertContains($needle, iterable $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param mixed $needle - * @see \Codeception\Module\AbstractAsserts::assertContainsEquals() - */ - public function assertContainsEquals($needle, iterable $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a haystack contains only values of a given type. - * @see \Codeception\Module\AbstractAsserts::assertContainsOnly() - */ - public function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = NULL, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnly', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a haystack contains only instances of a given class name. - * @see \Codeception\Module\AbstractAsserts::assertContainsOnlyInstancesOf() - */ - public function assertContainsOnlyInstancesOf(string $className, iterable $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContainsOnlyInstancesOf', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts the number of elements of an array, Countable or Traversable. - * - * @param \Countable|iterable $haystack - * @see \Codeception\Module\AbstractAsserts::assertCount() - */ - public function assertCount(int $expectedCount, $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory does not exist. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryDoesNotExist() - */ - public function assertDirectoryDoesNotExist(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryDoesNotExist', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory exists. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryExists() - */ - public function assertDirectoryExists(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory exists and is not readable. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotReadable() - */ - public function assertDirectoryIsNotReadable(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory exists and is not writable. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsNotWritable() - */ - public function assertDirectoryIsNotWritable(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsNotWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory exists and is readable. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsReadable() - */ - public function assertDirectoryIsReadable(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a directory exists and is writable. - * @see \Codeception\Module\AbstractAsserts::assertDirectoryIsWritable() - */ - public function assertDirectoryIsWritable(string $directory, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDirectoryIsWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string does not match a given regular expression. - * @see \Codeception\Module\AbstractAsserts::assertDoesNotMatchRegularExpression() - */ - public function assertDoesNotMatchRegularExpression(string $pattern, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertDoesNotMatchRegularExpression', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is empty. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertEmpty() - */ - public function assertEmpty($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are equal. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertEquals() - */ - public function assertEquals($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are equal (canonicalizing). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertEqualsCanonicalizing() - */ - public function assertEqualsCanonicalizing($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are equal (ignoring case). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertEqualsIgnoringCase() - */ - public function assertEqualsIgnoringCase($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are equal (with delta). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertEqualsWithDelta() - */ - public function assertEqualsWithDelta($expected, $actual, float $delta, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEqualsWithDelta', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a condition is false. - * - * @param mixed $condition - * @see \Codeception\Module\AbstractAsserts::assertFalse() - */ - public function assertFalse($condition, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file does not exist. - * @see \Codeception\Module\AbstractAsserts::assertFileDoesNotExist() - */ - public function assertFileDoesNotExist(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileDoesNotExist', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is equal to the contents of another file. - * @see \Codeception\Module\AbstractAsserts::assertFileEquals() - */ - public function assertFileEquals(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is equal to the contents of another file (canonicalizing). - * @see \Codeception\Module\AbstractAsserts::assertFileEqualsCanonicalizing() - */ - public function assertFileEqualsCanonicalizing(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is equal to the contents of another file (ignoring case). - * @see \Codeception\Module\AbstractAsserts::assertFileEqualsIgnoringCase() - */ - public function assertFileEqualsIgnoringCase(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileEqualsIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file exists. - * @see \Codeception\Module\AbstractAsserts::assertFileExists() - */ - public function assertFileExists(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file exists and is not readable. - * @see \Codeception\Module\AbstractAsserts::assertFileIsNotReadable() - */ - public function assertFileIsNotReadable(string $file, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file exists and is not writable. - * @see \Codeception\Module\AbstractAsserts::assertFileIsNotWritable() - */ - public function assertFileIsNotWritable(string $file, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsNotWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file exists and is readable. - * @see \Codeception\Module\AbstractAsserts::assertFileIsReadable() - */ - public function assertFileIsReadable(string $file, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file exists and is writable. - * @see \Codeception\Module\AbstractAsserts::assertFileIsWritable() - */ - public function assertFileIsWritable(string $file, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileIsWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is not equal to the contents of another file. - * @see \Codeception\Module\AbstractAsserts::assertFileNotEquals() - */ - public function assertFileNotEquals(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is not equal to the contents of another file (canonicalizing). - * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsCanonicalizing() - */ - public function assertFileNotEqualsCanonicalizing(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of one file is not equal to the contents of another file (ignoring case). - * @see \Codeception\Module\AbstractAsserts::assertFileNotEqualsIgnoringCase() - */ - public function assertFileNotEqualsIgnoringCase(string $expected, string $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotEqualsIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is finite. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertFinite() - */ - public function assertFinite($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFinite', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is greater than another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertGreaterThan() - */ - public function assertGreaterThan($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is greater than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertGreaterThanOrEqual() - */ - public function assertGreaterThanOrEqual($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is infinite. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertInfinite() - */ - public function assertInfinite($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInfinite', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of a given type. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertInstanceOf() - */ - public function assertInstanceOf(string $expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type array. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsArray() - */ - public function assertIsArray($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsArray', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type bool. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsBool() - */ - public function assertIsBool($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsBool', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type callable. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsCallable() - */ - public function assertIsCallable($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsCallable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type resource and is closed. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsClosedResource() - */ - public function assertIsClosedResource($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsClosedResource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type float. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsFloat() - */ - public function assertIsFloat($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsFloat', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type int. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsInt() - */ - public function assertIsInt($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsInt', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type iterable. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsIterable() - */ - public function assertIsIterable($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsIterable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type array. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotArray() - */ - public function assertIsNotArray($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotArray', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type bool. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotBool() - */ - public function assertIsNotBool($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotBool', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type callable. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotCallable() - */ - public function assertIsNotCallable($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotCallable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type resource. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotClosedResource() - */ - public function assertIsNotClosedResource($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotClosedResource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type float. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotFloat() - */ - public function assertIsNotFloat($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotFloat', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type int. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotInt() - */ - public function assertIsNotInt($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotInt', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type iterable. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotIterable() - */ - public function assertIsNotIterable($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotIterable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type numeric. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotNumeric() - */ - public function assertIsNotNumeric($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotNumeric', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type object. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotObject() - */ - public function assertIsNotObject($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotObject', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file/dir exists and is not readable. - * @see \Codeception\Module\AbstractAsserts::assertIsNotReadable() - */ - public function assertIsNotReadable(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type resource. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotResource() - */ - public function assertIsNotResource($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotResource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type scalar. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotScalar() - */ - public function assertIsNotScalar($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotScalar', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of type string. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNotString() - */ - public function assertIsNotString($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file/dir exists and is not writable. - * @see \Codeception\Module\AbstractAsserts::assertIsNotWritable() - */ - public function assertIsNotWritable(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNotWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type numeric. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsNumeric() - */ - public function assertIsNumeric($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsNumeric', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type object. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsObject() - */ - public function assertIsObject($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsObject', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file/dir is readable. - * @see \Codeception\Module\AbstractAsserts::assertIsReadable() - */ - public function assertIsReadable(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsReadable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type resource. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsResource() - */ - public function assertIsResource($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsResource', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type scalar. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsScalar() - */ - public function assertIsScalar($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsScalar', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is of type string. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertIsString() - */ - public function assertIsString($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a file/dir exists and is writable. - * @see \Codeception\Module\AbstractAsserts::assertIsWritable() - */ - public function assertIsWritable(string $filename, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsWritable', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string is a valid JSON string. - * @see \Codeception\Module\AbstractAsserts::assertJson() - */ - public function assertJson(string $actualJson, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJson', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two JSON files are equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonFileEqualsJsonFile() - */ - public function assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileEqualsJsonFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two JSON files are not equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonFileNotEqualsJsonFile() - */ - public function assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonFileNotEqualsJsonFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the generated JSON encoded object and the content of the given file are equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonFile() - */ - public function assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two given JSON encoded objects or arrays are equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonStringEqualsJsonString() - */ - public function assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringEqualsJsonString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the generated JSON encoded object and the content of the given file are not equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonFile() - */ - public function assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two given JSON encoded objects or arrays are not equal. - * @see \Codeception\Module\AbstractAsserts::assertJsonStringNotEqualsJsonString() - */ - public function assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertJsonStringNotEqualsJsonString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is smaller than another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertLessThan() - */ - public function assertLessThan($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a value is smaller than or equal to another value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertLessThanOrEqual() - */ - public function assertLessThanOrEqual($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string matches a given regular expression. - * @see \Codeception\Module\AbstractAsserts::assertMatchesRegularExpression() - */ - public function assertMatchesRegularExpression(string $pattern, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertMatchesRegularExpression', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is nan. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNan() - */ - public function assertNan($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNan', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a haystack does not contain a needle. - * - * @param mixed $needle - * @see \Codeception\Module\AbstractAsserts::assertNotContains() - */ - public function assertNotContains($needle, iterable $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\AbstractAsserts::assertNotContainsEquals() - */ - public function assertNotContainsEquals($needle, iterable $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a haystack does not contain only values of a given type. - * @see \Codeception\Module\AbstractAsserts::assertNotContainsOnly() - */ - public function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = NULL, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContainsOnly', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts the number of elements of an array, Countable or Traversable. - * - * @param \Countable|iterable $haystack - * @see \Codeception\Module\AbstractAsserts::assertNotCount() - */ - public function assertNotCount(int $expectedCount, $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotCount', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not empty. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotEmpty() - */ - public function assertNotEmpty($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are not equal. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotEquals() - */ - public function assertNotEquals($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are not equal (canonicalizing). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotEqualsCanonicalizing() - */ - public function assertNotEqualsCanonicalizing($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are not equal (ignoring case). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotEqualsIgnoringCase() - */ - public function assertNotEqualsIgnoringCase($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables are not equal (with delta). - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotEqualsWithDelta() - */ - public function assertNotEqualsWithDelta($expected, $actual, float $delta, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEqualsWithDelta', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a condition is not false. - * - * @param mixed $condition - * @see \Codeception\Module\AbstractAsserts::assertNotFalse() - */ - public function assertNotFalse($condition, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotFalse', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not of a given type. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotInstanceOf() - */ - public function assertNotInstanceOf(string $expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is not null. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotNull() - */ - public function assertNotNull($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables do not have the same type and value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNotSame() - */ - public function assertNotSame($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same. - * - * @param \Countable|iterable $expected - * @param \Countable|iterable $actual - * @see \Codeception\Module\AbstractAsserts::assertNotSameSize() - */ - public function assertNotSameSize($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSameSize', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a condition is not true. - * - * @param mixed $condition - * @see \Codeception\Module\AbstractAsserts::assertNotTrue() - */ - public function assertNotTrue($condition, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotTrue', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a variable is null. - * - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertNull() - */ - public function assertNull($actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that an object has a specified attribute. - * @see \Codeception\Module\AbstractAsserts::assertObjectHasAttribute() - */ - public function assertObjectHasAttribute(string $attributeName, object $object, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectHasAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that an object does not have a specified attribute. - * @see \Codeception\Module\AbstractAsserts::assertObjectNotHasAttribute() - */ - public function assertObjectNotHasAttribute(string $attributeName, object $object, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertObjectNotHasAttribute', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two variables have the same type and value. - * - * @param mixed $expected - * @param mixed $actual - * @see \Codeception\Module\AbstractAsserts::assertSame() - */ - public function assertSame($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same. - * - * @param \Countable|iterable $expected - * @param \Countable|iterable $actual - * @see \Codeception\Module\AbstractAsserts::assertSameSize() - */ - public function assertSameSize($expected, $actual, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSameSize', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\AbstractAsserts::assertStringContainsString() - */ - public function assertStringContainsString(string $needle, string $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\AbstractAsserts::assertStringContainsStringIgnoringCase() - */ - public function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringContainsStringIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string ends not with a given suffix. - * @see \Codeception\Module\AbstractAsserts::assertStringEndsNotWith() - */ - public function assertStringEndsNotWith(string $suffix, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsNotWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string ends with a given suffix. - * @see \Codeception\Module\AbstractAsserts::assertStringEndsWith() - */ - public function assertStringEndsWith(string $suffix, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEndsWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is equal to the contents of a file. - * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFile() - */ - public function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is equal to the contents of a file (canonicalizing). - * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileCanonicalizing() - */ - public function assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is equal to the contents of a file (ignoring case). - * @see \Codeception\Module\AbstractAsserts::assertStringEqualsFileIgnoringCase() - */ - public function assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringEqualsFileIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string matches a given format string. - * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormat() - */ - public function assertStringMatchesFormat(string $format, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormat', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string matches a given format file. - * @see \Codeception\Module\AbstractAsserts::assertStringMatchesFormatFile() - */ - public function assertStringMatchesFormatFile(string $formatFile, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringMatchesFormatFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsString() - */ - public function assertStringNotContainsString(string $needle, string $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * - * @see \Codeception\Module\AbstractAsserts::assertStringNotContainsStringIgnoringCase() - */ - public function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotContainsStringIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is not equal to the contents of a file. - * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFile() - */ - public function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is not equal to the contents of a file (canonicalizing). - * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileCanonicalizing() - */ - public function assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileCanonicalizing', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that the contents of a string is not equal to the contents of a file (ignoring case). - * @see \Codeception\Module\AbstractAsserts::assertStringNotEqualsFileIgnoringCase() - */ - public function assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotEqualsFileIgnoringCase', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string does not match a given format string. - * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormat() - */ - public function assertStringNotMatchesFormat(string $format, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormat', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string does not match a given format string. - * @see \Codeception\Module\AbstractAsserts::assertStringNotMatchesFormatFile() - */ - public function assertStringNotMatchesFormatFile(string $formatFile, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringNotMatchesFormatFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string starts not with a given prefix. - * @see \Codeception\Module\AbstractAsserts::assertStringStartsNotWith() - */ - public function assertStringStartsNotWith(string $prefix, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a string starts with a given prefix. - * @see \Codeception\Module\AbstractAsserts::assertStringStartsWith() - */ - public function assertStringStartsWith(string $prefix, string $string, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Evaluates a PHPUnit\Framework\Constraint matcher object. - * - * @param mixed $value - * @see \Codeception\Module\AbstractAsserts::assertThat() - */ - public function assertThat($value, \PHPUnit\Framework\Constraint\Constraint $constraint, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertThat', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that a condition is true. - * - * @param mixed $condition - * @see \Codeception\Module\AbstractAsserts::assertTrue() - */ - public function assertTrue($condition, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML files are equal. - * @see \Codeception\Module\AbstractAsserts::assertXmlFileEqualsXmlFile() - */ - public function assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileEqualsXmlFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML files are not equal. - * @see \Codeception\Module\AbstractAsserts::assertXmlFileNotEqualsXmlFile() - */ - public function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlFileNotEqualsXmlFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML documents are equal. - * - * @param \DOMDocument|string $actualXml - * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlFile() - */ - public function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML documents are equal. - * - * @param \DOMDocument|string $expectedXml - * @param \DOMDocument|string $actualXml - * @see \Codeception\Module\AbstractAsserts::assertXmlStringEqualsXmlString() - */ - public function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringEqualsXmlString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML documents are not equal. - * - * @param \DOMDocument|string $actualXml - * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlFile() - */ - public function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlFile', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Asserts that two XML documents are not equal. - * - * @param \DOMDocument|string $expectedXml - * @param \DOMDocument|string $actualXml - * @see \Codeception\Module\AbstractAsserts::assertXmlStringNotEqualsXmlString() - */ - public function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('assertXmlStringNotEqualsXmlString', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Fails a test with the given message. - * @see \Codeception\Module\AbstractAsserts::fail() - */ - public function fail(string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Mark the test as incomplete. - * @see \Codeception\Module\AbstractAsserts::markTestIncomplete() - */ - public function markTestIncomplete(string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestIncomplete', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Mark the test as skipped. - * @see \Codeception\Module\AbstractAsserts::markTestSkipped() - */ - public function markTestSkipped(string $message = "") { - return $this->getScenario()->runStep(new \Codeception\Step\Action('markTestSkipped', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $key - * @param array|string|float|int|bool $value - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\LocatorHelper::setConfig() - */ - public function setConfig(string $key, $value): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('setConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $key - * @param array|string|float|int|bool $value - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::mockEnvironmentConfig() - */ - public function mockEnvironmentConfig(string $key, $value): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('mockEnvironmentConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * @param string|null $applicationName - * - * @throws \Exception - * - * @return \Spryker\Shared\Kernel\AbstractBundleConfig|null - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::mockConfigMethod() - */ - public function mockConfigMethod(string $methodName, $return, ?string $moduleName = NULL, ?string $applicationName = NULL): ?\Spryker\Shared\Kernel\AbstractBundleConfig { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockConfigMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Shared\Kernel\AbstractSharedConfig|null - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::mockSharedConfigMethod() - */ - public function mockSharedConfigMethod(string $methodName, $return, ?string $moduleName = NULL): ?\Spryker\Shared\Kernel\AbstractSharedConfig { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockSharedConfigMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $moduleName - * - * @return \Spryker\Shared\Kernel\AbstractBundleConfig - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::getModuleConfig() - */ - public function getModuleConfig(?string $moduleName = NULL): \Spryker\Shared\Kernel\AbstractBundleConfig { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getModuleConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $moduleName - * - * @return \Spryker\Shared\Kernel\AbstractSharedConfig|null - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::getSharedModuleConfig() - */ - public function getSharedModuleConfig(?string $moduleName = NULL): ?\Spryker\Shared\Kernel\AbstractSharedConfig { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getSharedModuleConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $moduleName - * - * @return bool - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::configExists() - */ - public function configExists(string $moduleName): bool { - return $this->getScenario()->runStep(new \Codeception\Step\Action('configExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $key - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\ConfigHelper::removeConfig() - */ - public function removeConfig(string $key): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('removeConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\DependencyHelper::clearFactoryContainerCache() - */ - public function clearFactoryContainerCache(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('clearFactoryContainerCache', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $key - * @param mixed $value - * @param string|null $onlyFor - * - * @return void - * @see \SprykerTest\Zed\Testify\Helper\AbstractDependencyProviderHelper::setDependency() - */ - public function setDependency($key, $value, $onlyFor = NULL) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('setDependency', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * Sets a class instance into the Locator cache to ensure the mocked instance is returned when - * `$locator->moduleName()->type()` is used. - * - * !!! When this method is used the locator will not re-initialize classes with `new` but will return - * always the already resolved instances. This can have but should not have side-effects. - * - * @param string $cacheKey - * @param mixed $classInstance - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\LocatorHelper::addToLocatorCache() - */ - public function addToLocatorCache(string $cacheKey, $classInstance): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('addToLocatorCache', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return bool - * @see \SprykerTest\Shared\Testify\Helper\LocatorHelper::isProjectNamespaceEnabled() - */ - public function isProjectNamespaceEnabled(): bool { - return $this->getScenario()->runStep(new \Codeception\Step\Action('isProjectNamespaceEnabled', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return \Spryker\Shared\Kernel\LocatorLocatorInterface&\Generated\Zed\Ide\AutoCompletion&\Generated\Service\Ide\AutoCompletion&\Generated\Glue\Ide\AutoCompletion - * @see \SprykerTest\Shared\Testify\Helper\LocatorHelper::getLocator() - */ - public function getLocator() { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getLocator', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $moduleName - * - * @return \Spryker\Zed\Kernel\Business\AbstractFacade - * @see \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper::getFacade() - */ - public function getFacade(?string $moduleName = NULL): \Spryker\Zed\Kernel\Business\AbstractFacade { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getFacade', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Zed\Kernel\Business\AbstractFacade - * @see \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper::mockFacadeMethod() - */ - public function mockFacadeMethod(string $methodName, $return, ?string $moduleName = NULL) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockFacadeMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Zed\Kernel\Business\AbstractBusinessFactory|object - * @see \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper::mockFactoryMethod() - */ - public function mockFactoryMethod(string $methodName, $return, ?string $moduleName = NULL) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockFactoryMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Zed\Kernel\Business\AbstractBusinessFactory|object - * @see \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper::mockSharedFactoryMethod() - */ - public function mockSharedFactoryMethod(string $methodName, $return, ?string $moduleName = NULL) { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockSharedFactoryMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $moduleName - * - * @return \Spryker\Zed\Kernel\Business\AbstractBusinessFactory - * @see \SprykerTest\Zed\Testify\Helper\Business\BusinessHelper::getFactory() - */ - public function getFactory(?string $moduleName = NULL): \Spryker\Zed\Kernel\Business\AbstractBusinessFactory { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getFactory', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return \Spryker\Service\Container\ContainerInterface - * @see \SprykerTest\Service\Container\Helper\ContainerHelper::getContainer() - */ - public function getContainer(): \Spryker\Service\Container\ContainerInterface { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getContainer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Zed\Kernel\Container - * @see \SprykerTest\Zed\Testify\Helper\AbstractDependencyProviderHelper::getModuleContainer() - */ - public function getModuleContainer(?string $moduleName = NULL): \Spryker\Zed\Kernel\Container { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getModuleContainer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $methodName - * @param mixed $return - * @param string|null $moduleName - * - * @throws \Exception - * - * @return \Spryker\Zed\Kernel\AbstractBundleDependencyProvider - * @see \SprykerTest\Zed\Testify\Helper\AbstractDependencyProviderHelper::mockDependencyProviderMethod() - */ - public function mockDependencyProviderMethod(string $methodName, $return, ?string $moduleName = NULL): \Spryker\Zed\Kernel\AbstractBundleDependencyProvider { - return $this->getScenario()->runStep(new \Codeception\Step\Action('mockDependencyProviderMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Zed\Testify\Helper\AbstractDependencyProviderHelper::cleanUp() - */ - public function cleanUp(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('cleanUp', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string|null $merchantReference - * - * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::createSalesOrderItemEntity() - */ - public function createSalesOrderItemEntity(?string $merchantReference = NULL): \Orm\Zed\Sales\Persistence\SpySalesOrderItem { - return $this->getScenario()->runStep(new \Codeception\Step\Action('createSalesOrderItemEntity', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seed - * - * @return \Orm\Zed\SalesPaymentMerchant\Persistence\SpySalesPaymentMerchantPayout - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::haveSalesPaymentMerchantPayoutPersisted() - */ - public function haveSalesPaymentMerchantPayoutPersisted(array $seed): \Orm\Zed\SalesPaymentMerchant\Persistence\SpySalesPaymentMerchantPayout { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveSalesPaymentMerchantPayoutPersisted', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seed - * - * @return \Orm\Zed\SalesPaymentMerchant\Persistence\SpySalesPaymentMerchantPayoutReversal - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::haveSalesPaymentMerchantPayoutReversalPersisted() - */ - public function haveSalesPaymentMerchantPayoutReversalPersisted(array $seed): \Orm\Zed\SalesPaymentMerchant\Persistence\SpySalesPaymentMerchantPayoutReversal { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveSalesPaymentMerchantPayoutReversalPersisted', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seed - * - * @return \Orm\Zed\Sales\Persistence\SpySalesOrder - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::createSalesOrderEntity() - */ - public function createSalesOrderEntity(array $seed): \Orm\Zed\Sales\Persistence\SpySalesOrder { - return $this->getScenario()->runStep(new \Codeception\Step\Action('createSalesOrderEntity', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $merchantReference - * @param string $orderReference - * @param array $salesOrderItems - * - * @return void - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::assertSalesPaymentMerchantPayoutEntity() - */ - public function assertSalesPaymentMerchantPayoutEntity(string $merchantReference, string $orderReference, array $salesOrderItems): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('assertSalesPaymentMerchantPayoutEntity', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $merchantReference - * @param string $orderReference - * @param array $salesOrderItems - * - * @return void - * @see \SprykerTest\Zed\SalesPaymentMerchant\Helper\SalesPaymentMerchantHelper::assertSalesPaymentMerchantRefundEntity() - */ - public function assertSalesPaymentMerchantRefundEntity(string $merchantReference, string $orderReference, array $salesOrderItems): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('assertSalesPaymentMerchantRefundEntity', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $override - * @param string|null $stateMachineProcessName - * @param array<\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface> $saveOrderStack - * - * @return \Generated\Shared\Transfer\SaveOrderTransfer - * @see \SprykerTest\Shared\Sales\Helper\SalesDataHelper::haveOrder() - */ - public function haveOrder(array $override = [], ?string $stateMachineProcessName = NULL, array $saveOrderStack = []): \Generated\Shared\Transfer\SaveOrderTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveOrder', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer - * @param string|null $stateMachineProcessName - * @param array<\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface> $checkoutDoSaveOrderPlugins - * - * @return \Generated\Shared\Transfer\SaveOrderTransfer - * @see \SprykerTest\Shared\Sales\Helper\SalesDataHelper::haveOrderFromQuote() - */ - public function haveOrderFromQuote(\Generated\Shared\Transfer\QuoteTransfer $quoteTransfer, ?string $stateMachineProcessName = NULL, array $checkoutDoSaveOrderPlugins = []): \Generated\Shared\Transfer\SaveOrderTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveOrderFromQuote', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param \Generated\Shared\Transfer\AddressTransfer $addressTransfer - * - * @return \Generated\Shared\Transfer\AddressTransfer - * @see \SprykerTest\Shared\Sales\Helper\SalesDataHelper::haveSalesOrderAddress() - */ - public function haveSalesOrderAddress(\Generated\Shared\Transfer\AddressTransfer $addressTransfer): \Generated\Shared\Transfer\AddressTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveSalesOrderAddress', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer - * @param string|null $stateMachineProcessName - * @param array<\Spryker\Zed\CheckoutExtension\Dependency\Plugin\CheckoutDoSaveOrderInterface> $saveOrderStack - * - * @return \Generated\Shared\Transfer\SaveOrderTransfer - * @see \SprykerTest\Shared\Sales\Helper\SalesDataHelper::haveOrderUsingPreparedQuoteTransfer() - */ - public function haveOrderUsingPreparedQuoteTransfer(\Generated\Shared\Transfer\QuoteTransfer $quoteTransfer, ?string $stateMachineProcessName = NULL, array $saveOrderStack = []): \Generated\Shared\Transfer\SaveOrderTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveOrderUsingPreparedQuoteTransfer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Sales\Helper\SalesDataHelper::cleanStaticProperty() - */ - public function cleanStaticProperty(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('cleanStaticProperty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seedData - * - * @return \Generated\Shared\Transfer\MerchantTransfer - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::haveMerchant() - */ - public function haveMerchant(array $seedData = []): \Generated\Shared\Transfer\MerchantTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveMerchant', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return \Generated\Shared\Transfer\MerchantTransfer - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::haveMerchantWithStore() - */ - public function haveMerchantWithStore(): \Generated\Shared\Transfer\MerchantTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveMerchantWithStore', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return \Generated\Shared\Transfer\StoreRelationTransfer - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::getStoreRelationTransfer() - */ - public function getStoreRelationTransfer(): \Generated\Shared\Transfer\StoreRelationTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getStoreRelationTransfer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param int $idMerchant - * - * @return void - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::assertMerchantNotExists() - */ - public function assertMerchantNotExists(int $idMerchant): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('assertMerchantNotExists', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return \Spryker\Zed\Merchant\MerchantConfig - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::createMerchantConfig() - */ - public function createMerchantConfig(): \Spryker\Zed\Merchant\MerchantConfig { - return $this->getScenario()->runStep(new \Codeception\Step\Action('createMerchantConfig', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seedData - * - * @return \Generated\Shared\Transfer\MerchantTransfer - * @see \SprykerTest\Zed\Merchant\Helper\MerchantHelper::getMerchantTransfer() - */ - public function getMerchantTransfer(array $seedData = []): \Generated\Shared\Transfer\MerchantTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('getMerchantTransfer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param \Closure $closure - * - * @return void - * @see \SprykerTest\Shared\Testify\Helper\DataCleanupHelper::addCleanup() - */ - public function addCleanup(\Closure $closure): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('addCleanup', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seed - * - * @return \Generated\Shared\Transfer\SalesPaymentMethodTypeTransfer - * @see \SprykerTest\Zed\SalesPayment\Helper\SalesPaymentHelper::haveSalesPaymentMethodTypePersisted() - */ - public function haveSalesPaymentMethodTypePersisted(array $seed = []): \Generated\Shared\Transfer\SalesPaymentMethodTypeTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveSalesPaymentMethodTypePersisted', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seed - * - * @return \Generated\Shared\Transfer\SalesPaymentTransfer - * @see \SprykerTest\Zed\SalesPayment\Helper\SalesPaymentHelper::haveSalesPaymentPersisted() - */ - public function haveSalesPaymentPersisted(array $seed = []): \Generated\Shared\Transfer\SalesPaymentTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveSalesPaymentPersisted', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param string $messageClassName - * @param array $properties - * - * @return void - * @see \SprykerTest\Zed\SalesPayment\Helper\SalesPaymentHelper::assertSentMessageProperties() - */ - public function assertSentMessageProperties(string $messageClassName, array $properties): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('assertSentMessageProperties', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::ensurePaymentMethodTableIsEmpty() - */ - public function ensurePaymentMethodTableIsEmpty(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('ensurePaymentMethodTableIsEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::ensurePaymentMethodStoreTableIsEmpty() - */ - public function ensurePaymentMethodStoreTableIsEmpty(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('ensurePaymentMethodStoreTableIsEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::ensurePaymentProviderTableIsEmpty() - */ - public function ensurePaymentProviderTableIsEmpty(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('ensurePaymentProviderTableIsEmpty', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $override - * - * @return \Generated\Shared\Transfer\PaymentProviderTransfer - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::havePaymentProvider() - */ - public function havePaymentProvider(array $override = []): \Generated\Shared\Transfer\PaymentProviderTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('havePaymentProvider', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $override - * - * @return \Generated\Shared\Transfer\PaymentMethodTransfer - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::havePaymentMethod() - */ - public function havePaymentMethod(array $override = []): \Generated\Shared\Transfer\PaymentMethodTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('havePaymentMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param \Generated\Shared\Transfer\PaymentMethodTransfer $paymentMethodTransfer - * - * @return \Generated\Shared\Transfer\PaymentMethodTransfer|null - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::findPaymentMethod() - */ - public function findPaymentMethod(\Generated\Shared\Transfer\PaymentMethodTransfer $paymentMethodTransfer): ?\Generated\Shared\Transfer\PaymentMethodTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('findPaymentMethod', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seedData - * @param array $messageAttributesSeedData - * - * @return \Generated\Shared\Transfer\AddPaymentMethodTransfer - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::haveAddPaymentMethodTransfer() - */ - public function haveAddPaymentMethodTransfer(array $seedData = [], array $messageAttributesSeedData = []): \Generated\Shared\Transfer\AddPaymentMethodTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveAddPaymentMethodTransfer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param array $seedData - * - * @return \Generated\Shared\Transfer\DeletePaymentMethodTransfer - * @see \SprykerTest\Shared\Payment\Helper\PaymentDataHelper::haveDeletePaymentMethodTransfer() - */ - public function haveDeletePaymentMethodTransfer(array $seedData = []): \Generated\Shared\Transfer\DeletePaymentMethodTransfer { - return $this->getScenario()->runStep(new \Codeception\Step\Action('haveDeletePaymentMethodTransfer', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return int - * @see \SprykerTest\Shared\Sales\Helper\SalesHelper::createOrder() - */ - public function createOrder(): int { - return $this->getScenario()->runStep(new \Codeception\Step\Action('createOrder', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @return void - * @see \SprykerTest\Shared\Sales\Helper\SalesHelper::createOrderWithOneItem() - */ - public function createOrderWithOneItem(): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('createOrderWithOneItem', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param int $idSalesOrder - * @param array $salesOrderItem - * - * @return \Orm\Zed\Sales\Persistence\SpySalesOrderItem - * @see \SprykerTest\Shared\Sales\Helper\SalesHelper::createSalesOrderItemForOrder() - */ - public function createSalesOrderItemForOrder(int $idSalesOrder, array $salesOrderItem = []): \Orm\Zed\Sales\Persistence\SpySalesOrderItem { - return $this->getScenario()->runStep(new \Codeception\Step\Action('createSalesOrderItemForOrder', func_get_args())); - } - - - /** - * [!] Method is generated. Documentation taken from corresponding module. - * - * @param int $idSalesOrderItem - * @param array $discount - * - * @return void - * @see \SprykerTest\Shared\Sales\Helper\SalesHelper::createDiscountForSalesOrderItem() - */ - public function createDiscountForSalesOrderItem(int $idSalesOrderItem, array $discount = []): void { - $this->getScenario()->runStep(new \Codeception\Step\Action('createDiscountForSalesOrderItem', func_get_args())); - } -} diff --git a/tests/SprykerTest/Zed/SalesPaymentMerchant/codeception.yml b/tests/SprykerTest/Zed/SalesPaymentMerchant/codeception.yml index 1094e59..0e992cf 100644 --- a/tests/SprykerTest/Zed/SalesPaymentMerchant/codeception.yml +++ b/tests/SprykerTest/Zed/SalesPaymentMerchant/codeception.yml @@ -33,3 +33,4 @@ suites: - \SprykerTest\Zed\SalesPayment\Helper\SalesPaymentHelper - \SprykerTest\Shared\Payment\Helper\PaymentDataHelper - \SprykerTest\Shared\Sales\Helper\SalesHelper + - \SprykerTest\Shared\Store\Helper\StoreDataHelper