From 9dbffdb79420ee17f5ab0c2917531266e41194e1 Mon Sep 17 00:00:00 2001 From: Yuxing Zheng <yuxzheng@ebay.com> Date: Tue, 21 Apr 2015 16:55:09 -0500 Subject: [PATCH] MAGETWO-36378: Magento\Quote\Api\GuestCartManagement - Remove \Magento\Quote\Model\GuestCart\GuestCartManagement::getCartForCustomer - Remove $quoteRepository from the parameters of GuestCartManagement::__construct - Update unit test accordingly --- .../Model/GuestCart/GuestCartManagement.php | 22 ------------------- .../GuestCart/GuestCartManagementTest.php | 16 -------------- 2 files changed, 38 deletions(-) diff --git a/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php b/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php index 62966b0c86f..243c70f95e1 100644 --- a/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php +++ b/app/code/Magento/Quote/Model/GuestCart/GuestCartManagement.php @@ -10,8 +10,6 @@ use Magento\Quote\Api\GuestCartManagementInterface; use Magento\Quote\Api\CartManagementInterface; use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteIdMaskFactory; -use Magento\Quote\Model\QuoteManagement; -use Magento\Quote\Model\QuoteRepository; /** * Cart Management class for guest carts. @@ -25,11 +23,6 @@ class GuestCartManagement implements GuestCartManagementInterface */ protected $quoteManagement; - /** - * @var QuoteRepository - */ - protected $quoteRepository; - /** * @var QuoteIdMaskFactory */ @@ -39,17 +32,14 @@ class GuestCartManagement implements GuestCartManagementInterface * Initialize dependencies. * * @param CartManagementInterface $quoteManagement - * @param QuoteRepository $quoteRepository * @param QuoteIdMaskFactory $quoteIdMaskFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( CartManagementInterface $quoteManagement, - QuoteRepository $quoteRepository, QuoteIdMaskFactory $quoteIdMaskFactory ) { $this->quoteManagement = $quoteManagement; - $this->quoteRepository = $quoteRepository; $this->quoteIdMaskFactory = $quoteIdMaskFactory; } @@ -84,16 +74,4 @@ class GuestCartManagement implements GuestCartManagementInterface $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); return $this->quoteManagement->placeOrder($quoteIdMask->getId()); } - - /** - * {@inheritdoc} - */ - public function getCartForCustomer($customerId) - { - $cart = $this->quoteRepository->getActiveForCustomer($customerId); - /** @var $quoteIdMask QuoteIdMask */ - $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cart->getId(), 'masked_id'); - $cart->setId($quoteIdMask->getId()); - return $cart; - } } diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php index cc567b0262f..444aa62322a 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartManagementTest.php @@ -47,7 +47,6 @@ class GuestCartManagementTest extends \PHPUnit_Framework_TestCase true, [] ); - $this->quoteRepositoryMock = $this->getMock('Magento\Quote\Model\QuoteRepository', [], [], '', false); $this->quoteIdMaskFactoryMock = $this->getMock( 'Magento\Quote\Model\QuoteIdMaskFactory', ['create'], @@ -67,7 +66,6 @@ class GuestCartManagementTest extends \PHPUnit_Framework_TestCase 'Magento\Quote\Model\GuestCart\GuestCartManagement', [ 'quoteManagement' => $this->quoteManagementMock, - 'quoteRepository' => $this->quoteRepositoryMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock ] ); @@ -115,18 +113,4 @@ class GuestCartManagementTest extends \PHPUnit_Framework_TestCase $this->assertEquals($orderId, $this->guestCartManagement->placeOrder($cartId)); } - - public function testGetCartForCustomer() - { - $maskedCartId = 'masked1cart2id3'; - $cartId = 1; - $orderId = 1; - - $this->quoteIdMaskMock->expects($this->once())->method('load')->with($cartId, 'masked_id')->willReturnSelf(); - $this->quoteIdMaskMock->expects($this->once())->method('getId')->willReturn($maskedCartId); - $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteIdMaskMock); - $this->quoteManagementMock->expects($this->once())->method('placeOrder')->willReturn($orderId); - - $this->assertEquals($orderId, $this->guestCartManagement->placeOrder($cartId)); - } } -- GitLab