diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 213587d2a12a7024d311f65a77e1209980412858..f1bea24b085a76a729b2bf92043ce615979d6065 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -74,6 +74,11 @@ class Quote extends \Magento\Framework\Session\SessionManager */ protected $groupManagement; + /** + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + /** * @param \Magento\Framework\App\Request\Http $request * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -89,7 +94,7 @@ class Quote extends \Magento\Framework\Session\SessionManager * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param GroupManagementInterface $groupManagement - * @throws \Magento\Framework\Exception\SessionException + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -106,13 +111,15 @@ class Quote extends \Magento\Framework\Session\SessionManager \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - GroupManagementInterface $groupManagement + GroupManagementInterface $groupManagement, + \Magento\Quote\Model\QuoteFactory $quoteFactory ) { $this->customerRepository = $customerRepository; $this->quoteRepository = $quoteRepository; $this->_orderFactory = $orderFactory; $this->_storeManager = $storeManager; $this->groupManagement = $groupManagement; + $this->quoteFactory = $quoteFactory; parent::__construct( $request, $sidResolver, @@ -137,7 +144,7 @@ class Quote extends \Magento\Framework\Session\SessionManager public function getQuote() { if ($this->_quote === null) { - $this->_quote = $this->quoteRepository->create(); + $this->_quote = $this->quoteFactory->create(); if ($this->getStoreId()) { if (!$this->getQuoteId()) { $this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId()) diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index a643fc59f1156993d0cfbe1cbab58e389749fd28..56ead2c90c697ed4be5dca15d530b9e3c1f198d3 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -86,6 +86,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase */ protected $groupManagementMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + /** * Set up * @@ -190,6 +195,8 @@ class QuoteTest extends \PHPUnit_Framework_TestCase false ); + $this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', [], [], '', false); + $this->quote = $this->getMock( 'Magento\Backend\Model\Session\Quote', ['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'], @@ -208,6 +215,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase 'orderFactory' => $this->orderFactoryMock, 'storeManager' => $this->storeManagerMock, 'groupManagement' => $this->groupManagementMock, + 'quoteFactory' => $this->quoteFactoryMock ], '', true @@ -296,7 +304,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase ->method('setIsSuperMode') ->with(true); - $this->quoteRepositoryMock->expects($this->once()) + $this->quoteFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($quoteMock)); $this->quoteRepositoryMock->expects($this->once()) @@ -371,7 +379,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase ->method('getCustomerId') ->will($this->returnValue($quoteCustomerId)); - $this->quoteRepositoryMock->expects($this->once()) + $this->quoteFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($quoteMock)); $this->quoteRepositoryMock->expects($this->once()) diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index 010cc1d19f4d6a83c4dddec2857e802d2cb99e59..ba51d052accb2a06586e3a4032be0f4d8f95e3ba 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -92,6 +92,11 @@ class Session extends \Magento\Framework\Session\SessionManager */ protected $isQuoteMasked; + /** + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + /** * @param \Magento\Framework\App\Request\Http $request * @param \Magento\Framework\Session\SidResolverInterface $sidResolver @@ -110,8 +115,7 @@ class Session extends \Magento\Framework\Session\SessionManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param QuoteIdMaskFactory $quoteIdMaskFactory - * @throws \Magento\Framework\Exception\SessionException - * @codeCoverageIgnore + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -131,7 +135,8 @@ class Session extends \Magento\Framework\Session\SessionManager \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdMaskFactory $quoteIdMaskFactory, + \Magento\Quote\Model\QuoteFactory $quoteFactory ) { $this->_orderFactory = $orderFactory; $this->_customerSession = $customerSession; @@ -141,6 +146,7 @@ class Session extends \Magento\Framework\Session\SessionManager $this->_storeManager = $storeManager; $this->customerRepository = $customerRepository; $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->quoteFactory = $quoteFactory; parent::__construct( $request, $sidResolver, @@ -203,7 +209,7 @@ class Session extends \Magento\Framework\Session\SessionManager $this->_eventManager->dispatch('custom_quote_process', ['checkout_session' => $this]); if ($this->_quote === null) { - $quote = $this->quoteRepository->create(); + $quote = $this->quoteFactory->create(); if ($this->getQuoteId()) { try { if ($this->_loadInactive) { @@ -321,7 +327,7 @@ class Session extends \Magento\Framework\Session\SessionManager try { $customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId()); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $customerQuote = $this->quoteRepository->create(); + $customerQuote = $this->quoteFactory->create(); } $customerQuote->setStoreId($this->_storeManager->getStore()->getId()); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php index 932cd1d6ee89b6bef2b0de8751416b1b01e82d95..8e61f5300dc0c8d1b5420f4dfbc018328290a7e1 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php @@ -41,12 +41,18 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended */ protected $_parentTemplate; + /** + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository * @param \Magento\Framework\Data\CollectionFactory $dataCollectionFactory * @param \Magento\Framework\Registry $coreRegistry + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @param array $data */ public function __construct( @@ -55,11 +61,13 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\Data\CollectionFactory $dataCollectionFactory, \Magento\Framework\Registry $coreRegistry, + \Magento\Quote\Model\QuoteFactory $quoteFactory, array $data = [] ) { $this->_dataCollectionFactory = $dataCollectionFactory; $this->_coreRegistry = $coreRegistry; $this->quoteRepository = $quoteRepository; + $this->quoteFactory = $quoteFactory; parent::__construct($context, $backendHelper, $data); } @@ -230,7 +238,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended try { $this->quote = $this->quoteRepository->getForCustomer($customerId, $storeIds); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $this->quote = $this->quoteRepository->create()->setSharedStoreIds($storeIds); + $this->quote = $this->quoteFactory->create()->setSharedStoreIds($storeIds); } } return $this->quote; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php index 95b5cd0926843305c4c46229c6067c741be252ac..734d0f1fa66ba71f59a8c7128c827e75b62769d8 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php @@ -38,13 +38,17 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended protected $quote = null; /** - * Constructor - * + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository * @param \Magento\Framework\Data\CollectionFactory $dataCollectionFactory * @param \Magento\Framework\Registry $coreRegistry + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @param array $data */ public function __construct( @@ -53,11 +57,13 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\Data\CollectionFactory $dataCollectionFactory, \Magento\Framework\Registry $coreRegistry, + \Magento\Quote\Model\QuoteFactory $quoteFactory, array $data = [] ) { $this->_dataCollectionFactory = $dataCollectionFactory; $this->_coreRegistry = $coreRegistry; $this->quoteRepository = $quoteRepository; + $this->quoteFactory = $quoteFactory; parent::__construct($context, $backendHelper, $data); } @@ -159,7 +165,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended { if (null == $this->quote) { $storeIds = $this->_storeManager->getWebsite($this->getWebsiteId())->getStoreIds(); - $this->quote = $this->quoteRepository->create()->setSharedStoreIds($storeIds); + $this->quote = $this->quoteFactory->create()->setSharedStoreIds($storeIds); $currentCustomerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); if (!empty($currentCustomerId)) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php index 903e691be6ad272b5ad1c09f32bfd75e057c6c79..6032048815cf68018e326b47d4c58d224563f2c6 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php @@ -41,15 +41,23 @@ abstract class Cart extends \Magento\Backend\App\Action */ protected $quoteRepository; + /** + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + /** * @param Action\Context $context * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory */ public function __construct( Action\Context $context, - \Magento\Quote\Api\CartRepositoryInterface $quoteRepository + \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, + \Magento\Quote\Model\QuoteFactory $quoteFactory ) { $this->quoteRepository = $quoteRepository; + $this->quoteFactory = $quoteFactory; parent::__construct($context); } @@ -72,7 +80,7 @@ abstract class Cart extends \Magento\Backend\App\Action try { $this->_quote = $this->quoteRepository->getForCustomer($this->_customerId); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $this->_quote = $this->quoteRepository->create(); + $this->_quote = $this->quoteFactory->create(); } $this->_quote->setWebsite( $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php index d6c36217182d83b853cd5f27c70b7d262b963927..f74c2e7c5a632636ab22c882adb1d0b8e87ea11a 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php @@ -28,7 +28,7 @@ class Cart extends \Magento\Customer\Controller\Adminhtml\Index try { $quote = $quoteRepository->getForCustomer($customerId); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - $quote = $quoteRepository->create(); + $quote = $this->_objectManager->create('\Magento\Quote\Model\QuoteFactory')->create(); } $quote->setWebsite( $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getWebsite($websiteId) diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 54cd258ce2c6f8d3e37dc77f4fd0229bb26f6b09..76c56739e840d8755721ef060d2ac89f0a2d7c2a 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -119,6 +119,11 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface */ protected $accountManagement; + /** + * @var QuoteFactory + */ + protected $quoteFactory; + /** * @param EventManager $eventManager * @param QuoteValidator $quoteValidator @@ -138,6 +143,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Api\AccountManagementInterface $accountManagement + * @param QuoteFactory $quoteFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -158,7 +164,8 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface StoreManagerInterface $storeManager, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, - \Magento\Customer\Api\AccountManagementInterface $accountManagement + \Magento\Customer\Api\AccountManagementInterface $accountManagement, + \Magento\Quote\Model\QuoteFactory $quoteFactory ) { $this->eventManager = $eventManager; $this->quoteValidator = $quoteValidator; @@ -178,6 +185,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface $this->checkoutSession = $checkoutSession; $this->accountManagement = $accountManagement; $this->customerSession = $customerSession; + $this->quoteFactory = $quoteFactory; } /** @@ -256,7 +264,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface protected function createAnonymousCart($storeId) { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->create(); + $quote = $this->quoteFactory->create(); $quote->setStoreId($storeId); return $quote; } @@ -277,7 +285,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface $quote = $this->quoteRepository->getActiveForCustomer($customerId); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->quoteRepository->create(); + $quote = $this->quoteFactory->create(); $quote->setStoreId($storeId); $quote->setCustomer($customer); $quote->setCustomerIsGuest(0); diff --git a/app/code/Magento/Quote/Model/QuoteRepository.php b/app/code/Magento/Quote/Model/QuoteRepository.php index 014e8759a117e567a941a5872620fa70643692ca..d788275f40fffecfe12e82b07abb964f818c26ef 100644 --- a/app/code/Magento/Quote/Model/QuoteRepository.php +++ b/app/code/Magento/Quote/Model/QuoteRepository.php @@ -77,17 +77,6 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor; } - /** - * Create new quote - * - * @param array $data - * @return Quote - */ - public function create(array $data = []) - { - return $this->quoteFactory->create($data); - } - /** * {@inheritdoc} */ diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php index e318617d88e0b0a59f0fab16b57d84a07b1e1276..2c05f399faf14fbfcd8129c7872fcb5f24d01032 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php @@ -6,7 +6,6 @@ namespace Magento\Quote\Test\Unit\Model; -use \Magento\Quote\Api\CartManagementInterface; use \Magento\Quote\Model\CustomerManagement; use \Magento\Framework\Exception\NoSuchEntityException; @@ -18,7 +17,7 @@ use \Magento\Framework\Exception\NoSuchEntityException; class QuoteManagementTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Quote\Api\CartManagementInterface + * @var \Magento\Quote\Model\QuoteManagement */ protected $model; @@ -117,6 +116,11 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase */ protected $quoteMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteFactoryMock; + /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -220,8 +224,10 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase false ); + $this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', [], [], '', false); + $this->model = $objectManager->getObject( - '\Magento\Quote\Api\CartManagementInterface', + '\Magento\Quote\Model\QuoteManagement', [ 'eventManager' => $this->eventManager, 'quoteValidator' => $this->quoteValidator, @@ -241,6 +247,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase 'checkoutSession' => $this->checkoutSessionMock, 'customerSession' => $this->customerSessionMock, 'accountManagement' => $this->accountManagementMock, + 'quoteFactory' => $this->quoteFactoryMock ] ); } @@ -252,7 +259,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); - $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($quoteMock); + $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($quoteMock); $quoteMock->expects($this->any())->method('setStoreId')->with($storeId); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); @@ -278,7 +285,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->with($userId) ->willThrowException(new NoSuchEntityException()); - $this->quoteRepositoryMock->expects($this->once())->method('create')->willReturn($quoteMock); + $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($quoteMock); $quoteMock->expects($this->any())->method('setStoreId')->with($storeId); $quoteMock->expects($this->any())->method('setCustomerIsGuest')->with(0); @@ -303,7 +310,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->method('getActiveForCustomer') ->with($userId)->willReturn($quoteMock); - $this->quoteRepositoryMock->expects($this->never())->method('create')->willReturn($quoteMock); + $this->quoteFactoryMock->expects($this->never())->method('create')->willReturn($quoteMock); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturnSelf(); @@ -663,9 +670,9 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase ->method('setCustomerGroupId') ->with(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID); - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Api\CartManagementInterface $service */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ $service = $this->getMock( - '\Magento\Quote\Api\CartManagementInterface', + '\Magento\Quote\Model\QuoteManagement', ['submit'], [ 'eventManager' => $this->eventManager, @@ -686,6 +693,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase 'checkoutSession' => $this->checkoutSessionMock, 'customerSession' => $this->customerSessionMock, 'accountManagement' => $this->accountManagementMock, + 'quoteFactory' => $this->quoteFactoryMock ] ); $orderMock = $this->getMock( @@ -719,9 +727,9 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase $orderIncrementId = 100003332; $orderStatus = 'status1'; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Api\CartManagementInterface $service */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */ $service = $this->getMock( - '\Magento\Quote\Api\CartManagementInterface', + '\Magento\Quote\Model\QuoteManagement', ['submit'], [ 'eventManager' => $this->eventManager, @@ -742,6 +750,7 @@ class QuoteManagementTest extends \PHPUnit_Framework_TestCase 'checkoutSession' => $this->checkoutSessionMock, 'customerSession' => $this->customerSessionMock, 'accountManagement' => $this->accountManagementMock, + 'quoteFactory' => $this->quoteFactoryMock ] ); $orderMock = $this->getMock( diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php index f416395c55e8f62a41283d780e651cad6b2cec75..a6a2a8fe6280b8f97a7484ec0f18f950f038feda 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php @@ -109,21 +109,6 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase ); } - public function testCreate() - { - $this->quoteFactoryMock->expects($this->once()) - ->method('create') - ->with([1, 2, 3]) - ->willReturn($this->quoteMock); - $this->storeManagerMock->expects($this->never())->method('getStore'); - $this->storeMock->expects($this->never())->method('getId'); - $this->quoteMock->expects($this->never())->method('setSharedStoreIds'); - $this->quoteMock->expects($this->never())->method('load'); - $this->quoteMock->expects($this->never())->method('getId'); - - $this->assertEquals($this->quoteMock, $this->model->create([1, 2, 3])); - } - /** * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage No such entity with cartId = 14 diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 8ff52f86f159674b176f3a9a22984acd42289094..0f3c58cfd6098bdf8b93ad9bc8b1d4b33218b894 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -219,6 +219,11 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ */ protected $orderManagement; + /** + * @var \Magento\Quote\Model\QuoteFactory + */ + protected $quoteFactory; + /** * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -246,6 +251,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ * @param \Magento\Quote\Api\CartManagementInterface $quoteManagement * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Magento\Sales\Api\OrderManagementInterface $orderManagement + * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -276,6 +282,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ \Magento\Quote\Api\CartManagementInterface $quoteManagement, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Sales\Api\OrderManagementInterface $orderManagement, + \Magento\Quote\Model\QuoteFactory $quoteFactory, array $data = [] ) { $this->_objectManager = $objectManager; @@ -304,6 +311,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ $this->quoteManagement = $quoteManagement; $this->dataObjectHelper = $dataObjectHelper; $this->orderManagement = $orderManagement; + $this->quoteFactory = $quoteFactory; parent::__construct($data); } @@ -681,7 +689,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ return $this->_cart; } - $this->_cart = $this->quoteRepository->create(); + $this->_cart = $this->quoteFactory->create(); $customerId = (int)$this->getSession()->getCustomerId(); if ($customerId) { diff --git a/composer.lock b/composer.lock index 9da039729694a59f2cb2ed8d294c322ed126c17a..537209c8733994d072f8e90b715a062b07612039 100644 --- a/composer.lock +++ b/composer.lock @@ -5,7 +5,6 @@ "This file is @generated automatically" ], "hash": "80867d6202a3ae5d2f4c079e2cfd702f", - "content-hash": "41493176956dcfd2401ac1181d4d4782", "packages": [ { "name": "braintree/braintree_php", @@ -2571,16 +2570,16 @@ }, { "name": "fabpot/php-cs-fixer", - "version": "v1.10.1", + "version": "v1.10.2", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a" + "reference": "e8b3c4e41dc1484210fdc45363c41af6c2d56f20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", - "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/e8b3c4e41dc1484210fdc45363c41af6c2d56f20", + "reference": "e8b3c4e41dc1484210fdc45363c41af6c2d56f20", "shasum": "" }, "require": { @@ -2621,7 +2620,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2015-10-12 20:13:46" + "time": "2015-10-21 19:19:43" }, { "name": "league/climate",