Skip to content

Commit 0c8460e

Browse files
committed
MAGETWO-9007: Get MAGETWO-52856 into Magento 2.1.x
1 parent 0c04a86 commit 0c8460e

File tree

3 files changed

+188
-446
lines changed

3 files changed

+188
-446
lines changed

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,28 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
5454

5555
/**
5656
* @param \Magento\Quote\Api\BillingAddressManagementInterface $billingAddressManagement
57-
* @param \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement
58-
* @param \Magento\Quote\Api\CartManagementInterface $cartManagement
59-
* @param PaymentDetailsFactory $paymentDetailsFactory
60-
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
57+
* @param \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement
58+
* @param \Magento\Quote\Api\CartManagementInterface $cartManagement
59+
* @param PaymentDetailsFactory $paymentDetailsFactory
60+
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
61+
* @param \Magento\Quote\Api\CartRepositoryInterface|null $cartRepository
6162
* @codeCoverageIgnore
6263
*/
6364
public function __construct(
6465
\Magento\Quote\Api\BillingAddressManagementInterface $billingAddressManagement,
6566
\Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement,
6667
\Magento\Quote\Api\CartManagementInterface $cartManagement,
6768
\Magento\Checkout\Model\PaymentDetailsFactory $paymentDetailsFactory,
68-
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
69+
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository,
70+
\Magento\Quote\Api\CartRepositoryInterface $cartRepository = null
6971
) {
7072
$this->billingAddressManagement = $billingAddressManagement;
7173
$this->paymentMethodManagement = $paymentMethodManagement;
7274
$this->cartManagement = $cartManagement;
7375
$this->paymentDetailsFactory = $paymentDetailsFactory;
7476
$this->cartTotalsRepository = $cartTotalsRepository;
77+
$this->cartRepository = $cartRepository ? : \Magento\Framework\App\ObjectManager::getInstance()
78+
->get(\Magento\Quote\Api\CartRepositoryInterface::class);
7579
}
7680

7781
/**
@@ -110,10 +114,8 @@ public function savePaymentInformation(
110114
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
111115
) {
112116
if ($billingAddress) {
113-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
114-
$quoteRepository = $this->getCartRepository();
115117
/** @var \Magento\Quote\Model\Quote $quote */
116-
$quote = $quoteRepository->getActive($cartId);
118+
$quote = $this->cartRepository->getActive($cartId);
117119
$quote->removeAddress($quote->getBillingAddress()->getId());
118120
$quote->setBillingAddress($billingAddress);
119121
$quote->setDataChanges(true);
@@ -155,19 +157,4 @@ private function getLogger()
155157
}
156158
return $this->logger;
157159
}
158-
159-
/**
160-
* Get Cart repository instance.
161-
*
162-
* @return \Magento\Quote\Api\CartRepositoryInterface
163-
* @deprecated
164-
*/
165-
private function getCartRepository()
166-
{
167-
if (!$this->cartRepository) {
168-
$this->cartRepository = \Magento\Framework\App\ObjectManager::getInstance()
169-
->get(\Magento\Quote\Api\CartRepositoryInterface::class);
170-
}
171-
return $this->cartRepository;
172-
}
173160
}

app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ protected function setUp()
5959
[
6060
'billingAddressManagement' => $this->billingAddressManagementMock,
6161
'paymentMethodManagement' => $this->paymentMethodManagementMock,
62-
'cartManagement' => $this->cartManagementMock
62+
'cartManagement' => $this->cartManagementMock,
63+
'cartRepository' => $this->cartRepositoryMock
6364
]
6465
);
6566
$objectManager->setBackwardCompatibleProperty($this->model, 'logger', $this->loggerMock);
66-
$objectManager->setBackwardCompatibleProperty($this->model, 'cartRepository', $this->cartRepositoryMock);
6767
}
6868

6969
public function testSavePaymentInformationAndPlaceOrder()

0 commit comments

Comments
 (0)