Skip to content

Commit

Permalink
ENGCOM-4687: [Backport] ISSUE-5021 fixed guest checkout with custom s…
Browse files Browse the repository at this point in the history
…hipping carrier with underscores #21340
  • Loading branch information
sivaschenko authored Apr 18, 2019
2 parents 77de966 + 08016a9 commit bffe14c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Magento\Quote\Model\Quote;

/**
* Guest payment information management model.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPaymentInformationManagementInterface
Expand Down Expand Up @@ -65,7 +67,7 @@ class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPa
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $paymentInformationManagement
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param CartRepositoryInterface $cartRepository
* @param ResourceConnection|null
* @param ResourceConnection $connectionPool
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -87,7 +89,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function savePaymentInformationAndPlaceOrder(
$cartId,
Expand Down Expand Up @@ -128,7 +130,7 @@ public function savePaymentInformationAndPlaceOrder(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function savePaymentInformation(
$cartId,
Expand All @@ -155,7 +157,7 @@ public function savePaymentInformation(
}

/**
* {@inheritDoc}
* @inheritdoc
*/
public function getPaymentInformation($cartId)
{
Expand Down Expand Up @@ -189,9 +191,8 @@ private function limitShippingCarrier(Quote $quote)
{
$shippingAddress = $quote->getShippingAddress();
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
$shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
$shippingCarrier = array_shift($shippingDataArray);
$shippingAddress->setLimitCarrier($shippingCarrier);
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$billingAddressId = 1;
$quote = $this->createMock(Quote::class);
$quoteBillingAddress = $this->createMock(Address::class);
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
$shippingRate->setCarrier('flatrate');
$quoteShippingAddress = $this->createPartialMock(
Address::class,
['setLimitCarrier', 'getShippingMethod']
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
);
$this->cartRepositoryMock->method('getActive')
->with($cartId)
Expand All @@ -302,6 +304,9 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
$quote->expects($this->once())
->method('setBillingAddress')
->with($billingAddressMock);
$quoteShippingAddress->expects($this->any())
->method('getShippingRateByCode')
->willReturn($shippingRate);
$quote->expects($this->once())
->method('setDataChanges')
->willReturnSelf();
Expand Down

0 comments on commit bffe14c

Please sign in to comment.