Skip to content

Commit

Permalink
ISSUE-5021 fixed guest checkout for custom shipping carrier with unde…
Browse files Browse the repository at this point in the history
…rscores
  • Loading branch information
vovsky committed Dec 1, 2018
1 parent 5498231 commit 2360efd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ private function limitShippingCarrier(Quote $quote) : void
{
$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 @@ -273,7 +273,7 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
*/
private function getMockForAssignBillingAddress(
int $cartId,
\PHPUnit_Framework_MockObject_MockObject $billingAddressMock
\PHPUnit_Framework_MockObject_MockObject $billingAddressMock
) : void {
$quoteIdMask = $this->createPartialMock(QuoteIdMask::class, ['getQuoteId', 'load']);
$this->quoteIdMaskFactoryMock->method('create')
Expand All @@ -287,9 +287,11 @@ private function getMockForAssignBillingAddress(
$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 @@ -309,6 +311,9 @@ private function getMockForAssignBillingAddress(
$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 2360efd

Please sign in to comment.