Skip to content

Commit

Permalink
Merge pull request #69 from magento-folks/jsonapi_compliant
Browse files Browse the repository at this point in the history
[Folks] Bugfix
  • Loading branch information
Idolov, Stanislav(sidolov) committed Oct 30, 2015
2 parents eacba1c + 1d3f003 commit cd08089
Show file tree
Hide file tree
Showing 110 changed files with 570 additions and 1,681 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ protected function _returnCustomerQuote($cancelOrder = false, $errorMsg = '')
$order = $this->_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId);
if ($order->getId()) {
try {
/** @var \Magento\Quote\Model\QuoteRepository $quoteRepository */
$quoteRepository = $this->_objectManager->create('Magento\Quote\Model\QuoteRepository');
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
$quoteRepository = $this->_objectManager->create('Magento\Quote\Api\CartRepositoryInterface');
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $quoteRepository->get($order->getQuoteId());

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
protected $storeManager;

/**
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand Down Expand Up @@ -136,7 +136,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param OrderSender $orderSender
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
Expand All @@ -161,7 +161,7 @@ public function __construct(
ZendClientFactory $httpClientFactory,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
\Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
Expand Down
19 changes: 13 additions & 6 deletions app/code/Magento/Backend/Model/Session/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Quote extends \Magento\Framework\Session\SessionManager
/**
* Sales quote repository
*
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand All @@ -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
Expand All @@ -85,11 +90,11 @@ class Quote extends \Magento\Framework\Session\SessionManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\State $appState
* @param CustomerRepositoryInterface $customerRepository
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @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(
Expand All @@ -103,16 +108,18 @@ public function __construct(
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Framework\App\State $appState,
CustomerRepositoryInterface $customerRepository,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\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,
Expand All @@ -137,7 +144,7 @@ public function __construct(
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())
Expand Down
21 changes: 12 additions & 9 deletions app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/**
* Class QuoteTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
*/
class QuoteTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -86,6 +87,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
*/
protected $groupManagementMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $quoteFactoryMock;

/**
* Set up
*
Expand Down Expand Up @@ -122,13 +128,7 @@ protected function setUp()
true,
['getValue']
);
$this->quoteRepositoryMock = $this->getMock(
'Magento\Quote\Model\QuoteRepository',
['create', 'save', 'get'],
[],
'',
false
);
$this->quoteRepositoryMock = $this->getMock('Magento\Quote\Api\CartRepositoryInterface');

$this->requestMock = $this->getMock(
'Magento\Framework\App\Request\Http',
Expand Down Expand Up @@ -196,6 +196,8 @@ protected function setUp()
false
);

$this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', ['create'], [], '', false);

$this->quote = $this->getMock(
'Magento\Backend\Model\Session\Quote',
['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'],
Expand All @@ -214,6 +216,7 @@ protected function setUp()
'orderFactory' => $this->orderFactoryMock,
'storeManager' => $this->storeManagerMock,
'groupManagement' => $this->groupManagementMock,
'quoteFactory' => $this->quoteFactoryMock
],
'',
true
Expand Down Expand Up @@ -302,7 +305,7 @@ public function testGetQuoteWithoutQuoteId()
->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())
Expand Down Expand Up @@ -377,7 +380,7 @@ public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expected
->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())
Expand Down
7 changes: 2 additions & 5 deletions app/code/Magento/Braintree/Test/Unit/Model/CheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase
protected $shippingAddressMock;

/**
* @var \Magento\Quote\Model\QuoteRepository|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Quote\Api\CartRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $quoteRepositoryMock;

Expand All @@ -73,10 +73,7 @@ protected function setUp()
$this->quoteMock->expects($this->any())
->method('getShippingAddress')
->willReturn($this->shippingAddressMock);
$this->quoteRepositoryMock = $this->getMockBuilder('\Magento\Quote\Model\QuoteRepository')
->disableOriginalConstructor()
->getMock();

$this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface');
$configMock = $this->getMockBuilder('\Magento\Paypal\Model\Config')
->disableOriginalConstructor()
->getMock();
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Checkout/Controller/Cart/CouponPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CouponPost extends \Magento\Checkout\Controller\Cart
/**
* Sales quote repository
*
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand All @@ -29,7 +29,7 @@ class CouponPost extends \Magento\Checkout\Controller\Cart
* @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
* @param \Magento\Checkout\Model\Cart $cart
* @param \Magento\SalesRule\Model\CouponFactory $couponFactory
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -40,7 +40,7 @@ public function __construct(
\Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
\Magento\Checkout\Model\Cart $cart,
\Magento\SalesRule\Model\CouponFactory $couponFactory,
\Magento\Quote\Model\QuoteRepository $quoteRepository
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository
) {
parent::__construct(
$context,
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Checkout/Controller/Cart/EstimatePost.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class EstimatePost extends \Magento\Checkout\Controller\Cart
{
/**
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand All @@ -22,7 +22,7 @@ class EstimatePost extends \Magento\Checkout\Controller\Cart
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
* @param CustomerCart $cart
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -32,7 +32,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
CustomerCart $cart,
\Magento\Quote\Model\QuoteRepository $quoteRepository
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository
) {
$this->quoteRepository = $quoteRepository;
parent::__construct(
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Checkout/Controller/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class Onepage extends Action
protected $layoutFactory;

/**
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand Down Expand Up @@ -91,7 +91,7 @@ abstract class Onepage extends Action
* @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
Expand All @@ -110,7 +110,7 @@ public function __construct(
\Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\View\LayoutFactory $layoutFactory,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Checkout/Model/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Cart extends DataObject implements CartInterface
protected $stockState;

/**
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand All @@ -100,7 +100,7 @@ class Cart extends DataObject implements CartInterface
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
* @param \Magento\CatalogInventory\Api\StockStateInterface $stockState
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param ProductRepositoryInterface $productRepository
* @param array $data
* @codeCoverageIgnore
Expand All @@ -116,7 +116,7 @@ public function __construct(
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
\Magento\CatalogInventory\Api\StockStateInterface $stockState,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
ProductRepositoryInterface $productRepository,
array $data = []
) {
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Checkout/Model/Cart/CollectQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CollectQuote
protected $shippingMethodManager;

/**
* @var \Magento\Quote\Model\QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected $quoteRepository;

Expand All @@ -43,7 +43,7 @@ class CollectQuote
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
* @param \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory
* @param \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @codeCoverageIgnore
*/
public function __construct(
Expand All @@ -52,7 +52,7 @@ public function __construct(
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
\Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory,
\Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager,
\Magento\Quote\Model\QuoteRepository $quoteRepository
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository
) {
$this->customerSession = $customerSession;
$this->customerRepository = $customerRepository;
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Checkout/Model/DefaultConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Magento\Framework\App\Http\Context as HttpContext;
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Locale\CurrencyInterface as CurrencyManager;
use Magento\Quote\Model\QuoteRepository;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\CartItemRepositoryInterface as QuoteItemRepository;
use Magento\Quote\Api\ShippingMethodManagementInterface as ShippingMethodManager;
use Magento\Catalog\Helper\Product\ConfigurationPool;
Expand Down Expand Up @@ -63,7 +63,7 @@ class DefaultConfigProvider implements ConfigProviderInterface
private $httpContext;

/**
* @var QuoteRepository
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
private $quoteRepository;

Expand Down Expand Up @@ -169,7 +169,7 @@ class DefaultConfigProvider implements ConfigProviderInterface
* @param CustomerSession $customerSession
* @param CustomerUrlManager $customerUrlManager
* @param HttpContext $httpContext
* @param QuoteRepository $quoteRepository
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param QuoteItemRepository $quoteItemRepository
* @param ShippingMethodManager $shippingMethodManager
* @param ConfigurationPool $configurationPool
Expand Down Expand Up @@ -199,7 +199,7 @@ public function __construct(
CustomerSession $customerSession,
CustomerUrlManager $customerUrlManager,
HttpContext $httpContext,
QuoteRepository $quoteRepository,
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
QuoteItemRepository $quoteItemRepository,
ShippingMethodManager $shippingMethodManager,
ConfigurationPool $configurationPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPa
protected $cartManagement;

/**
* @var \Magento\Checkout\Model\PaymentInformationManagement
* @var \Magento\Checkout\Api\PaymentInformationManagementInterface
*/
protected $paymentInformationManagement;

Expand All @@ -45,7 +45,7 @@ class GuestPaymentInformationManagement implements \Magento\Checkout\Api\GuestPa
* @param \Magento\Quote\Api\GuestBillingAddressManagementInterface $billingAddressManagement
* @param \Magento\Quote\Api\GuestPaymentMethodManagementInterface $paymentMethodManagement
* @param \Magento\Quote\Api\GuestCartManagementInterface $cartManagement
* @param PaymentInformationManagement $paymentInformationManagement
* @param \Magento\Checkout\Api\PaymentInformationManagementInterface $paymentInformationManagement
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param CartRepositoryInterface $cartRepository
* @codeCoverageIgnore
Expand All @@ -54,7 +54,7 @@ public function __construct(
\Magento\Quote\Api\GuestBillingAddressManagementInterface $billingAddressManagement,
\Magento\Quote\Api\GuestPaymentMethodManagementInterface $paymentMethodManagement,
\Magento\Quote\Api\GuestCartManagementInterface $cartManagement,
\Magento\Checkout\Model\PaymentInformationManagement $paymentInformationManagement,
\Magento\Checkout\Api\PaymentInformationManagementInterface $paymentInformationManagement,
\Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory,
CartRepositoryInterface $cartRepository
) {
Expand Down
Loading

0 comments on commit cd08089

Please sign in to comment.