From 6b0058a1841f6d1253328515848c3de4fb0ae166 Mon Sep 17 00:00:00 2001 From: Bryant Luk <bluk@ebay.com> Date: Tue, 21 Apr 2015 18:16:20 -0500 Subject: [PATCH] MAGETWO-36427: Magento\Quote\Api\GuestShippingMethodManagement - Fix unit tests to use GuestCartTestHelper --- .../GuestCartTotalRepositoryTest.php | 20 ++++++------- .../GuestShippingMethodManagementTest.php | 30 +++++++------------ 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php index 4d39e8edeea..4db02b5caf1 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartTotalRepositoryTest.php @@ -57,6 +57,15 @@ class GuestCartTotalRepositoryTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; + $this->cartId = 123; + + $guestCartTestHelper = new GuestCartTestHelper($this); + list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask( + $this->maskedCartId, + $this->cartId + ); + $this->model = $this->objectManager->getObject( 'Magento\Quote\Model\GuestCart\GuestCartTotalRepository', [ @@ -64,17 +73,6 @@ class GuestCartTotalRepositoryTest extends \PHPUnit_Framework_TestCase 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, ] ); - - $this->quoteIdMaskFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->quoteIdMaskMock); - $this->quoteIdMaskMock->expects($this->once()) - ->method('load') - ->with($this->maskedCartId, 'masked_id') - ->willReturn($this->quoteIdMaskMock); - $this->quoteIdMaskMock->expects($this->once()) - ->method('getId') - ->willReturn($this->cartId); } public function testGetTotals() diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php index 07a83b5e281..c91510a165f 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestShippingMethodManagementTest.php @@ -46,12 +46,16 @@ class GuestShippingMethodManagementTest extends \PHPUnit_Framework_TestCase $this->shippingMethodManagementMock = $this->getMockBuilder('Magento\Quote\Api\ShippingMethodManagementInterface') ->getMockForAbstractClass(); - $this->quoteIdMaskFactoryMock = $this->getMockBuilder('Magento\Quote\Model\QuoteIdMaskFactory') - ->disableOriginalConstructor() - ->getMock(); - $this->quoteIdMaskMock = $this->getMockBuilder('Magento\Quote\Model\QuoteIdMask') - ->disableOriginalConstructor() - ->getMock(); + + $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; + $this->cartId = 867; + + $guestCartTestHelper = new GuestCartTestHelper($this); + list($this->quoteIdMaskFactoryMock, $this->quoteIdMaskMock) = $guestCartTestHelper->mockQuoteIdMask( + $this->maskedCartId, + $this->cartId + ); + $this->model = $objectManager->getObject( 'Magento\Quote\Model\GuestCart\GuestShippingMethodManagement', [ @@ -59,20 +63,6 @@ class GuestShippingMethodManagementTest extends \PHPUnit_Framework_TestCase 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, ] ); - - $this->maskedCartId = 'f216207248d65c789b17be8545e0aa73'; - $this->cartId = 867; - - $this->quoteIdMaskFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->quoteIdMaskMock); - $this->quoteIdMaskMock->expects($this->once()) - ->method('load') - ->with($this->maskedCartId, 'masked_id') - ->willReturn($this->quoteIdMaskMock); - $this->quoteIdMaskMock->expects($this->once()) - ->method('getId') - ->willReturn($this->cartId); } public function testSet() -- GitLab