From 13f34cd6e15c0e1ce1b1183761d3ca4bfc318c22 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Tue, 17 Dec 2019 15:14:50 -0300 Subject: [PATCH 1/4] Fixing #26083 --- app/code/Magento/Payment/Model/Info.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index 3b7f93be776ee..39a5a4cdc70a3 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -188,6 +188,7 @@ public function getAdditionalInformation($key = null) */ public function unsAdditionalInformation($key = null) { + $this->_initAdditionalInformation(); if ($key && isset($this->_additionalInformation[$key])) { unset($this->_additionalInformation[$key]); return $this->setData('additional_information', $this->_additionalInformation); From 32227d2773836da0574db70fac8aad46ac0dad83 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Tue, 17 Dec 2019 16:37:50 -0300 Subject: [PATCH 2/4] Removing an unnecessary , --- app/code/Magento/Payment/Model/Info.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index 39a5a4cdc70a3..3ca9b072e8321 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -38,7 +38,7 @@ class Info extends AbstractExtensibleModel implements InfoInterface * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory - * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource From ad1059fb9a0abb316a6cb92b62ef9fee546f1f77 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Fri, 27 Dec 2019 15:40:25 -0300 Subject: [PATCH 3/4] Adding coverage test cases, fixing Order/Payment/Info that had the same problem. --- .../Sales/Model/Order/Payment/Info.php | 1 + .../Magento/Payment/Model/PaymentInfoTest.php | 64 ++++++++++++++ .../Magento/Payment/_files/payment_info.php | 83 +++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php diff --git a/app/code/Magento/Sales/Model/Order/Payment/Info.php b/app/code/Magento/Sales/Model/Order/Payment/Info.php index fee846fe6a62c..479d96b5842d9 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Info.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Info.php @@ -192,6 +192,7 @@ public function getAdditionalInformation($key = null) */ public function unsAdditionalInformation($key = null) { + $this->initAdditionalInformation(); if ($key && isset($this->additionalInformation[$key])) { unset($this->additionalInformation[$key]); return $this->setData('additional_information', $this->additionalInformation); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php new file mode 100644 index 0000000000000..7a4efe4a22ce9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php @@ -0,0 +1,64 @@ +_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')); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php b/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php new file mode 100644 index 0000000000000..bf40cb6b99820 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Payment/_files/payment_info.php @@ -0,0 +1,83 @@ + 'guest', + 'lastname' => 'guest', + 'email' => 'customer@example.com', + '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('co@co.co') + ->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); From 408b725157f031a81119cb27816d204d48b45b97 Mon Sep 17 00:00:00 2001 From: Marco Oliveira Date: Fri, 27 Dec 2019 16:04:17 -0300 Subject: [PATCH 4/4] Removing unnecessary line. --- .../testsuite/Magento/Payment/Model/PaymentInfoTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php index 7a4efe4a22ce9..3d037ceb17044 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/PaymentInfoTest.php @@ -56,8 +56,7 @@ public function testUnsetPaymentInformation() /** @var \Magento\Quote\Model\Quote\Payment $paymentQuote */ $paymentQuote = $quote->getPayment(); $paymentQuote->unsAdditionalInformation('testing'); - - + $this->assertFalse($paymentOrder->hasAdditionalInformation('testing')); $this->assertFalse($paymentQuote->hasAdditionalInformation('testing')); }