Skip to content

Commit

Permalink
ACP-3468: Adjusted test
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4onok committed Jul 19, 2024
1 parent 8dfddce commit 34b9022
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Orm\Zed\AppPayment\Persistence\SpyPaymentRefund;
use Orm\Zed\AppPayment\Persistence\SpyPaymentTransfer;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Map\TableMap;

class PaymentMapper
{
Expand All @@ -23,19 +24,19 @@ public function mapPaymentTransferToPaymentEntity(PaymentTransfer $paymentTransf
$quoteJson = json_encode($quoteTransfer->toArray());
$additionalPaymentData = json_encode($paymentTransfer->getAdditionalPaymentData() ?? []);

$paymentData = $paymentTransfer->modifiedToArray();
$paymentData = $paymentTransfer->modifiedToArray(true, true);
$paymentData[PaymentTransfer::QUOTE] = $quoteJson;
$paymentData[PaymentTransfer::ADDITIONAL_PAYMENT_DATA] = $additionalPaymentData;

return $spyPayment->fromArray($paymentData);
return $spyPayment->fromArray($paymentData, TableMap::TYPE_CAMELNAME);
}

public function mapPaymentEntityToPaymentTransfer(SpyPayment $spyPayment, PaymentTransfer $paymentTransfer): PaymentTransfer
{
$quoteData = json_decode((string)$spyPayment->getQuote(), true);
$additionalPaymentData = json_decode((string)$spyPayment->getAdditionalPaymentData(), true);

$paymentData = $spyPayment->toArray();
$paymentData = $spyPayment->toArray(TableMap::TYPE_CAMELNAME);
$paymentData[PaymentTransfer::QUOTE] = $quoteData;
$paymentData[PaymentTransfer::ADDITIONAL_PAYMENT_DATA] = $additionalPaymentData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<column name="status" type="CHAR" size="64"/>
<column name="redirect_success_url" type="LONGVARCHAR"/>
<column name="redirect_cancel_url" type="LONGVARCHAR"/>
<column name="additionalPaymentData" type="BLOB"/>
<column name="additional_payment_data" type="LONGVARCHAR"/>

<unique name="spy_payment-unique-order_reference">
<unique-column name="order_reference"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CancelPaymentTest extends Unit
protected AppPaymentAsyncApiTester $tester;

/**
* @group test1
* Cancellable states are all states before a payment is captured. When a payment is captured, it cannot be cancelled anymore and only the refund operation is possible.
* This test will check if the payment is updated to PaymentStatusEnum::STATUS_CANCELLED when the CancelPayment message is received and the payment is in a cancellable state.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/app_payment.databuilder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<transfer name="Payment" strict="true">
<property name="redirectSuccessUrl" dataBuilderRule="url()"/>
<property name="redirectCancelUrl" dataBuilderRule="url()"/>
<property name="additionalPaymentData" dataBuilderRule="=[]"/>
<property name="additionalPaymentData" dataBuilderRule="shuffle(array())"/>
</transfer>

<transfer name="PaymentRefund" strict="true">
Expand Down

0 comments on commit 34b9022

Please sign in to comment.