-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-6524: Fix #26083 - problem with unsAdditionalInformation in \M…
…agento\Payment\Model\Info #26084
- Loading branch information
Showing
4 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Payment\Model; | ||
|
||
use Magento\Sales\Model\Order; | ||
use Magento\Quote\Model\Quote; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use Magento\TestFramework\ObjectManager; | ||
|
||
/** | ||
* @magentoAppArea adminhtml | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class PaymentInfoTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
protected $_objectManager; | ||
|
||
/** | ||
* @var Order | ||
*/ | ||
protected $_order; | ||
|
||
/** @var Quote */ | ||
protected $_quote; | ||
|
||
protected function setUp() | ||
{ | ||
$this->_objectManager = Bootstrap::getObjectManager(); | ||
$this->_order = $this->_objectManager->create( | ||
Order::class | ||
); | ||
$this->_quote = $this->_objectManager->create( | ||
Quote::class | ||
); | ||
} | ||
|
||
/** | ||
* @magentoDbIsolation enabled | ||
* @magentoAppIsolation enabled | ||
* @magentoDataFixture Magento/Payment/_files/payment_info.php | ||
*/ | ||
public function testUnsetPaymentInformation() | ||
{ | ||
$order = $this->_order->loadByIncrementId('100000001'); | ||
/** @var \Magento\Sales\Model\Order\Payment $paymentOrder */ | ||
$paymentOrder = $order->getPayment(); | ||
$paymentOrder->unsAdditionalInformation('testing'); | ||
|
||
$quote = $this->_quote->load('reserved_order_id', 'reserved_order_id'); | ||
/** @var \Magento\Quote\Model\Quote\Payment $paymentQuote */ | ||
$paymentQuote = $quote->getPayment(); | ||
$paymentQuote->unsAdditionalInformation('testing'); | ||
|
||
$this->assertFalse($paymentOrder->hasAdditionalInformation('testing')); | ||
$this->assertFalse($paymentQuote->hasAdditionalInformation('testing')); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
use Magento\Quote\Api\CartRepositoryInterface; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use Magento\Sales\Model\Order\Address; | ||
use Magento\Sales\Model\Order\Payment; | ||
use Magento\Paypal\Model\Config; | ||
use Magento\Sales\Model\Order; | ||
use Magento\Quote\Model\Quote; | ||
use Magento\Quote\Model\Quote\Payment as PaymentQuote; | ||
|
||
/** @var $objectManager \Magento\TestFramework\ObjectManager */ | ||
$objectManager = Bootstrap::getObjectManager(); | ||
|
||
$addressData = [ | ||
'firstname' => 'guest', | ||
'lastname' => 'guest', | ||
'email' => '[email protected]', | ||
'street' => 'street', | ||
'city' => 'Los Angeles', | ||
'region' => 'CA', | ||
'postcode' => '1', | ||
'country_id' => 'US', | ||
'telephone' => '1' | ||
]; | ||
$billingAddress = $objectManager->create( | ||
Address::class, | ||
['data' => $addressData] | ||
); | ||
$billingAddress->setAddressType('billing'); | ||
$shippingAddress = clone $billingAddress; | ||
$shippingAddress->setId(null)->setAddressType('shipping'); | ||
|
||
/** @var Payment $paymentOrder */ | ||
$paymentOrder = $objectManager->create( | ||
Payment::class | ||
); | ||
|
||
$paymentOrder->setMethod(Config::METHOD_WPP_EXPRESS); | ||
$paymentOrder->setAdditionalInformation('testing', 'testing additional data'); | ||
|
||
$amount = 100; | ||
|
||
/** @var Order $order */ | ||
$order = $objectManager->create(Order::class); | ||
$order->setCustomerEmail('[email protected]') | ||
->setIncrementId('100000001') | ||
->setSubtotal($amount) | ||
->setBaseSubtotal($amount) | ||
->setBaseGrandTotal($amount) | ||
->setGrandTotal($amount) | ||
->setBaseCurrencyCode('USD') | ||
->setCustomerIsGuest(true) | ||
->setStoreId(1) | ||
->setEmailSent(true) | ||
->setBillingAddress($billingAddress) | ||
->setShippingAddress($shippingAddress) | ||
->setPayment($paymentOrder); | ||
$order->save(); | ||
|
||
|
||
|
||
/** @var Quote $quote */ | ||
$quote = $objectManager->create(Quote::class); | ||
$quote->setStoreId(1) | ||
->setIsActive(true) | ||
->setIsMultiShipping(false) | ||
->setReservedOrderId('reserved_order_id'); | ||
|
||
$quote->getPayment() | ||
->setMethod(Config::METHOD_WPP_EXPRESS) | ||
->setAdditionalInformation('testing', 'testing additional data'); | ||
|
||
$quote->collectTotals(); | ||
|
||
|
||
/** @var CartRepositoryInterface $repository */ | ||
$repository = $objectManager->get(CartRepositoryInterface::class); | ||
$repository->save($quote); |