From 8a5689a367e0821368177e4fdcdbec027e9f75e3 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 6 Jul 2015 17:37:11 +0300 Subject: [PATCH 01/23] MAGETWO-39678: Can't create checkout with long term session --- app/code/Magento/Checkout/Controller/Index/Index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/Controller/Index/Index.php b/app/code/Magento/Checkout/Controller/Index/Index.php index 518ae5e30eba9..0bb9c2fe85104 100644 --- a/app/code/Magento/Checkout/Controller/Index/Index.php +++ b/app/code/Magento/Checkout/Controller/Index/Index.php @@ -15,6 +15,7 @@ class Index extends \Magento\Checkout\Controller\Onepage */ public function execute() { + /** @var \Magento\Checkout\Helper\Data $checkoutHelper */ $checkoutHelper = $this->_objectManager->get('Magento\Checkout\Helper\Data'); if (!$checkoutHelper->canOnepageCheckout()) { $this->messageManager->addError(__('One-page checkout is turned off.')); @@ -22,13 +23,12 @@ public function execute() } $quote = $this->getOnepage()->getQuote(); - - if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) { - $this->messageManager->addError(__('Guest checkout is disabled.')); + if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) { return $this->resultRedirectFactory->create()->setPath('checkout/cart'); } - if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) { + if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) { + $this->messageManager->addError(__('Guest checkout is disabled.')); return $this->resultRedirectFactory->create()->setPath('checkout/cart'); } From 26d818cedde13ebb9b3b75416611a75849b9c7c4 Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Mon, 6 Jul 2015 19:06:31 +0300 Subject: [PATCH 02/23] MAGETWO-39739: Cannot add product to shopping cart if Use Secure URLs on Storefront=Yes, but using non-secure connection --- .../Catalog/Helper/Product/Compare.php | 3 +- .../Test/Unit/Helper/Product/CompareTest.php | 53 +++++++++++++++++-- app/code/Magento/Checkout/Helper/Cart.php | 6 ++- .../Checkout/Test/Unit/Helper/CartTest.php | 3 ++ 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Helper/Product/Compare.php b/app/code/Magento/Catalog/Helper/Product/Compare.php index 447daccb10d61..504e990c86fb5 100644 --- a/app/code/Magento/Catalog/Helper/Product/Compare.php +++ b/app/code/Magento/Catalog/Helper/Product/Compare.php @@ -203,7 +203,8 @@ public function getAddToCartUrl($product) $beforeCompareUrl = $this->_catalogSession->getBeforeCompareUrl(); $params = [ 'product' => $product->getId(), - \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl) + \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl), + '_secure' => $this->_getRequest()->isSecure() ]; return $this->_getUrl('checkout/cart/add', $params); diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php index 33a0ef0eae931..228381f7d3b30 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php @@ -6,6 +6,8 @@ namespace Magento\Catalog\Test\Unit\Helper\Product; +use Magento\Framework\App\Action\Action; + /** * Class CompareTest */ @@ -41,12 +43,17 @@ class CompareTest extends \PHPUnit_Framework_TestCase */ protected $urlEncoder; + /** + * @var \Magento\Catalog\Model\Session | \PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogSessionMock; + public function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->urlBuilder = $this->getMock('Magento\Framework\Url', ['getUrl'], [], '', false); - $this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getServer'], [], '', false); + $this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getServer', 'isSecure'], [], '', false); /** @var \Magento\Framework\App\Helper\Context $context */ $this->context = $this->getMock( 'Magento\Framework\App\Helper\Context', @@ -58,7 +65,9 @@ public function setUp() $this->urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface')->getMock(); $this->urlEncoder->expects($this->any()) ->method('encode') - ->will($this->returnArgument(0)); + ->willReturnCallback(function ($url) { + return strtr(base64_encode($url), '+/=', '-_,'); + }); $this->context->expects($this->once()) ->method('getUrlBuilder') ->will($this->returnValue($this->urlBuilder)); @@ -75,10 +84,21 @@ public function setUp() '', false ); + $this->catalogSessionMock = $this->getMock( + '\Magento\Catalog\Model\Session', + ['getBeforeCompareUrl'], + [], + '', + false + ); $this->compareHelper = $objectManager->getObject( 'Magento\Catalog\Helper\Product\Compare', - ['context' => $this->context, 'postHelper' => $this->postDataHelper] + [ + 'context' => $this->context, + 'postHelper' => $this->postDataHelper, + 'catalogSession' => $this->catalogSessionMock + ] ); } @@ -89,7 +109,7 @@ public function testGetPostDataRemove() $removeUrl = 'catalog/product_compare/remove'; $compareListUrl = 'catalog/product_compare'; $postParams = [ - \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $compareListUrl, + Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($compareListUrl), '+/=', '-_,'), 'product' => $productId ]; @@ -136,7 +156,7 @@ public function testGetPostDataClearList() $refererUrl = 'home/'; $clearUrl = 'catalog/product_compare/clear'; $postParams = [ - \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $refererUrl + Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($refererUrl), '+/=', '-_,') ]; //Verification @@ -157,4 +177,27 @@ public function testGetPostDataClearList() $this->assertTrue($this->compareHelper->getPostDataClearList()); } + + public function testGetAddToCartUrl() + { + $productId = 42; + $isRequestSecure = false; + $beforeCompareUrl = 'http://magento.com/compare/before'; + $encodedCompareUrl = strtr(base64_encode($beforeCompareUrl), '+/=', '-_,'); + $expectedResult = [ + 'product' => $productId, + Action::PARAM_NAME_URL_ENCODED => $encodedCompareUrl, + '_secure' => $isRequestSecure + ]; + + $productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false); + $this->catalogSessionMock->expects($this->once())->method('getBeforeCompareUrl')->willReturn($beforeCompareUrl); + $productMock->expects($this->once())->method('getId')->willReturn($productId); + $this->urlEncoder->expects($this->once())->method('encode')->with($beforeCompareUrl) + ->willReturn($encodedCompareUrl); + $this->request->expects($this->once())->method('isSecure')->willReturn($isRequestSecure); + + $this->urlBuilder->expects($this->once())->method('getUrl')->with('checkout/cart/add', $expectedResult); + $this->compareHelper->getAddToCartUrl($productMock); + } } diff --git a/app/code/Magento/Checkout/Helper/Cart.php b/app/code/Magento/Checkout/Helper/Cart.php index 4a8d760741e95..b1443034b73a9 100644 --- a/app/code/Magento/Checkout/Helper/Cart.php +++ b/app/code/Magento/Checkout/Helper/Cart.php @@ -77,7 +77,11 @@ public function getAddUrl($product, $additional = []) $continueUrl = $this->urlEncoder->encode($this->_urlBuilder->getCurrentUrl()); $urlParamName = \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED; - $routeParams = [$urlParamName => $continueUrl, 'product' => $product->getEntityId()]; + $routeParams = [ + $urlParamName => $continueUrl, + 'product' => $product->getEntityId(), + '_secure' => $this->_getRequest()->isSecure() + ]; if (!empty($additional)) { $routeParams = array_merge($routeParams, $additional); diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php index c33ef261f889e..b656c5d4206ce 100644 --- a/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php @@ -155,6 +155,7 @@ public function testGetAddUrl() { $productEntityId = 1; $storeId = 1; + $isRequestSecure = false; $productMock = $this->getMock('\Magento\Catalog\Model\Product', ['getEntityId', 'hasUrlDataObject', 'getUrlDataObject', '__wakeup'], [], '', false); $productMock->expects($this->any())->method('getEntityId')->will($this->returnValue($productEntityId)); @@ -167,6 +168,7 @@ public function testGetAddUrl() $this->requestMock->expects($this->any())->method('getRouteName')->will($this->returnValue('checkout')); $this->requestMock->expects($this->any())->method('getControllerName')->will($this->returnValue('cart')); + $this->requestMock->expects($this->once())->method('isSecure')->willReturn($isRequestSecure); $params = [ Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($currentUrl), '+/=', '-_,'), @@ -175,6 +177,7 @@ public function testGetAddUrl() '_scope' => $storeId, '_scope_to_url' => true, 'in_cart' => 1, + '_secure' => $isRequestSecure ]; $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('checkout/cart/add', $params); From 7593f1ad397b2c99efcd24af755f00c55eb5f44b Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Mon, 6 Jul 2015 19:08:38 +0300 Subject: [PATCH 03/23] MAGETWO-38644: Output data Estimated Total and Cart Items Count on Checkout added sidebar --- .../Block/Checkout/TotalsProcessor.php | 6 +- .../frontend/layout/checkout_index_index.xml | 130 ++++++++++-------- .../view/frontend/web/js/model/sidebar.js | 28 ++++ .../view/frontend/web/js/view/estimation.js | 18 ++- .../web/js/view/shipping-information.js | 9 +- .../view/frontend/web/js/view/sidebar.js | 21 +++ .../frontend/web/template/estimation.html | 4 +- .../view/frontend/web/template/onepage.html | 27 +--- .../view/frontend/web/template/sidebar.html | 30 ++++ .../frontend/layout/checkout_index_index.xml | 16 ++- .../frontend/layout/checkout_index_index.xml | 94 +++++++------ .../frontend/layout/checkout_index_index.xml | 42 +++--- 12 files changed, 260 insertions(+), 165 deletions(-) create mode 100644 app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js create mode 100644 app/code/Magento/Checkout/view/frontend/web/js/view/sidebar.js create mode 100644 app/code/Magento/Checkout/view/frontend/web/template/sidebar.html diff --git a/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php b/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php index af5a8a51dd456..65315c2c33e13 100644 --- a/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php @@ -31,7 +31,8 @@ public function __construct( public function process($jsLayout) { $configData = $this->scopeConfig->getValue('sales/totals_sort'); - $totals = $jsLayout['components']['checkout']['children']['summary']['children']['totals']['children']; + $totals = $jsLayout['components']['checkout']['children']['sidebar']['children']['summary'] + ['children']['totals']['children']; foreach ($totals as $code => &$total) { //convert JS naming style to config naming style $code = str_replace('-', '_', $code); @@ -39,7 +40,8 @@ public function process($jsLayout) $total['sortOrder'] = $configData[$code]; } } - $jsLayout['components']['checkout']['children']['summary']['children']['totals']['children'] = $totals; + $jsLayout['components']['checkout']['children']['sidebar']['children']['summary'] + ['children']['totals']['children'] = $totals; return array_merge_recursive($jsLayout, $totals); } diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml index f6a5ba13a8401..2801b790a8e99 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml @@ -299,89 +299,99 @@ - - Magento_Checkout/js/view/summary - summary + + 50 + Magento_Checkout/js/view/sidebar + sidebar - Magento_Checkout/summary + Magento_Checkout/sidebar - - uiComponent - totals + + Magento_Checkout/js/view/summary + summary - Magento_Checkout/summary/totals + Magento_Checkout/summary - - - - Magento_Checkout/js/view/summary/subtotal + + uiComponent + totals - Cart Subtotal + Magento_Checkout/summary/totals - - - Magento_Checkout/js/view/summary/shipping - - Shipping - Not yet calculated + + + + + Magento_Checkout/js/view/summary/subtotal + + Cart Subtotal + + + + Magento_Checkout/js/view/summary/shipping + + Shipping + Not yet calculated + + + + Magento_Checkout/js/view/summary/grand-total + + Order Total + + - - Magento_Checkout/js/view/summary/grand-total - - Order Total + + uiComponent + + - - - - uiComponent - - - - - - Magento_Checkout/js/view/summary/cart-items - - - Magento_Checkout/js/view/summary/item/details + + Magento_Checkout/js/view/summary/cart-items - - Magento_Checkout/js/view/summary/item/details/thumbnail - before_details - - - Magento_Checkout/js/view/summary/item/details/subtotal - after_details + + Magento_Checkout/js/view/summary/item/details + + + Magento_Checkout/js/view/summary/item/details/thumbnail + before_details + + + Magento_Checkout/js/view/summary/item/details/subtotal + after_details + + + + + + + uiComponent + + - - - uiComponent + + Magento_Checkout/js/view/shipping-information + + checkout.steps.shipping-step.shippingAddress + + shipping-information - + + Magento_Checkout/js/view/shipping-information/list + ship-to + - - Magento_Checkout/js/view/shipping-information - - checkout.steps.shipping-step.shippingAddress - - shipping-information - - - Magento_Checkout/js/view/shipping-information/list - ship-to - - - diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js new file mode 100644 index 0000000000000..8241561babfc8 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js @@ -0,0 +1,28 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define( + [], + function() { + 'use strict'; + return { + popUp: false, + setPopup: function(popUp) { + this.popUp = popUp; + }, + show: function() { + if (this.popUp) { + this.popUp.modal('openModal'); + } + }, + hide: function() { + if (this.popUp) { + this.popUp.modal('closeModal'); + } + } + }; + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js index 23babcd44d8f9..27c89e2b6566a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js @@ -1,13 +1,19 @@ + define( [ - 'Magento_Checkout/js/view/summary/abstract-total', - 'Magento_Checkout/js/model/totals' + 'uiComponent', + 'Magento_Checkout/js/model/quote', + 'Magento_Catalog/js/price-utils', + 'Magento_Checkout/js/model/totals', + 'Magento_Checkout/js/model/sidebar', + 'Magento_Checkout/js/view/sidebar' ], - function (Component, totals) { + function (Component, quote, priceUtils, totals, sidebarModel) { 'use strict'; return Component.extend({ getQuantity: function() { @@ -22,6 +28,12 @@ define( } return 0; }, + showSidebar: function() { + sidebarModel.show(); + }, + getFormattedPrice: function (price) { + return priceUtils.formatPrice(price, quote.getPriceFormat()); + }, getValue: function () { return this.getFormattedPrice(this.getPureValue()); } diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js index d33dd69762f9c..678457699df6b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js @@ -10,9 +10,11 @@ define( 'uiComponent', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/shipping-service', - 'Magento_Checkout/js/model/step-navigator' + 'Magento_Checkout/js/model/step-navigator', + 'Magento_Checkout/js/model/sidebar', + 'Magento_Checkout/js/view/sidebar' ], - function($, Component, quote, shippingService, stepNavigator) { + function($, Component, quote, shippingService, stepNavigator, sidebarModel) { 'use strict'; return Component.extend({ defaults: { @@ -28,8 +30,7 @@ define( }, back: function() { - // Temp solution for closing summary sliding panel on mobile MAGETWO-3864 - $('#opc-sidebar').modal('toggleModal'); + sidebarModel.hide(); stepNavigator.back(); } }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/view/sidebar.js new file mode 100644 index 0000000000000..2f6161d4abd79 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/sidebar.js @@ -0,0 +1,21 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*global define*/ +define( + [ + 'uiComponent', + 'ko', + 'jquery', + 'Magento_Checkout/js/model/sidebar' + ], + function(Component, ko, $, sidebarModel) { + 'use strict'; + return Component.extend({ + setModalElement: function(element) { + sidebarModel.setPopup($(element)); + } + }); + } +); diff --git a/app/code/Magento/Checkout/view/frontend/web/template/estimation.html b/app/code/Magento/Checkout/view/frontend/web/template/estimation.html index cf7da50e0af92..af295c6f0f3b3 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/estimation.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/estimation.html @@ -7,10 +7,10 @@
- $120.00 +
-
-
- - - - - -
- - - -
-
+ + + diff --git a/app/code/Magento/Checkout/view/frontend/web/template/sidebar.html b/app/code/Magento/Checkout/view/frontend/web/template/sidebar.html new file mode 100644 index 0000000000000..ac187a3b8cd69 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/web/template/sidebar.html @@ -0,0 +1,30 @@ + + +
+ + + + + +
+ + + +
+
diff --git a/app/code/Magento/SalesRule/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/SalesRule/view/frontend/layout/checkout_index_index.xml index b9ba81bfaa8ec..b5ddc47cf8bae 100644 --- a/app/code/Magento/SalesRule/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/SalesRule/view/frontend/layout/checkout_index_index.xml @@ -33,14 +33,18 @@ - + - + - - Magento_SalesRule/js/view/summary/discount - - Discount + + + + Magento_SalesRule/js/view/summary/discount + + Discount + + diff --git a/app/code/Magento/Tax/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Tax/view/frontend/layout/checkout_index_index.xml index db20c4572b1d9..62de4a52b6925 100644 --- a/app/code/Magento/Tax/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/Tax/view/frontend/layout/checkout_index_index.xml @@ -29,57 +29,61 @@ - + - + - - - - Magento_Tax/js/view/checkout/summary/subtotal - - Excl. Tax - Incl. Tax - - - - Magento_Tax/js/view/checkout/summary/shipping - 20 - - Excl. Tax - Incl. Tax - - - - uiComponent - 30 + - - - - - Magento_Tax/js/view/checkout/summary/tax - - Tax - - - - Magento_Tax/js/view/checkout/summary/grand-total - - Order Total Excl. Tax - Order Total Incl. Tax - Your credit card will be charged for - Order Total + + + + Magento_Tax/js/view/checkout/summary/subtotal + + Excl. Tax + Incl. Tax + + + + Magento_Tax/js/view/checkout/summary/shipping + 20 + + Excl. Tax + Incl. Tax + + + + uiComponent + 30 + + + + + + Magento_Tax/js/view/checkout/summary/tax + + Tax + + + + Magento_Tax/js/view/checkout/summary/grand-total + + Order Total Excl. Tax + Order Total Incl. Tax + Your credit card will be charged for + Order Total + + - - - - - + - - Magento_Tax/js/view/checkout/summary/item/details/subtotal + + + + Magento_Tax/js/view/checkout/summary/item/details/subtotal + + diff --git a/app/code/Magento/Weee/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Weee/view/frontend/layout/checkout_index_index.xml index 6e3439d077586..78799c18cc519 100644 --- a/app/code/Magento/Weee/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/Weee/view/frontend/layout/checkout_index_index.xml @@ -14,31 +14,35 @@ - + - + - - Magento_Weee/js/view/checkout/summary/weee - - FPT + + + + Magento_Weee/js/view/checkout/summary/weee + + FPT + + - - - - - + - + - - Magento_Weee/js/view/checkout/summary/item/price/row_incl_tax - row_incl_tax - - - Magento_Weee/js/view/checkout/summary/item/price/row_excl_tax - row_excl_tax + + + + Magento_Weee/js/view/checkout/summary/item/price/row_incl_tax + row_incl_tax + + + Magento_Weee/js/view/checkout/summary/item/price/row_excl_tax + row_excl_tax + + From 7e2e22b93f764744220785df69a2026fbfcd3b70 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 7 Jul 2015 12:15:47 +0300 Subject: [PATCH 04/23] MAGETWO-38644: Output data Estimated Total and Cart Items Count on Checkout --- .../module/checkout/_estimated-total.less | 2 +- .../css/source/components/_modals_extend.less | 47 ++++++++++--------- .../module/checkout/_estimated-total.less | 2 +- .../source/module/checkout/_progress-bar.less | 5 +- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less index 5119231620d6e..49b1685d5340b 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less @@ -47,7 +47,7 @@ // Desktop // _____________________________________________ -.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) { +.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { .opc-estimated-wrapper { display: none; } diff --git a/app/design/frontend/Magento/blank/web/css/source/components/_modals_extend.less b/app/design/frontend/Magento/blank/web/css/source/components/_modals_extend.less index e4b01ecd0df6e..2d63705c1a135 100644 --- a/app/design/frontend/Magento/blank/web/css/source/components/_modals_extend.less +++ b/app/design/frontend/Magento/blank/web/css/source/components/_modals_extend.less @@ -97,28 +97,7 @@ // Mobile // _____________________________________________ -.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @modal-popup-breakpoint-screen__m) { - .modal-popup { - &.modal-slide { - .modal-inner-wrap[class] { - .css(background-color, @modal-slide-mobile__background-color); - } - &._inner-scroll { - &._show { - -webkit-overflow-scrolling: touch; - overflow-y: auto; - } - .modal-inner-wrap { - height: auto; - min-height: 100%; - } - } - } - .modal-title { - .css(font-size, @modal-popup-title-mobile__font-size); - .css(font-weight, @font-weight__bold); - } - } +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .custom-slide { .abs-modal(); .abs-modal-slide(); @@ -150,6 +129,30 @@ } } +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @modal-popup-breakpoint-screen__m) { + .modal-popup { + &.modal-slide { + .modal-inner-wrap[class] { + .css(background-color, @modal-slide-mobile__background-color); + } + &._inner-scroll { + &._show { + -webkit-overflow-scrolling: touch; + overflow-y: auto; + } + .modal-inner-wrap { + height: auto; + min-height: 100%; + } + } + } + .modal-title { + .css(font-size, @modal-popup-title-mobile__font-size); + .css(font-weight, @font-weight__bold); + } + } +} + // // Desktop // _____________________________________________ diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less index ccef519f1cbb1..7a189d7e3254a 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_estimated-total.less @@ -51,7 +51,7 @@ // Desktop // _____________________________________________ -.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) { +.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { .opc-estimated-wrapper { display: none; } diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_progress-bar.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_progress-bar.less index 13b59d044d72b..4e5d1e9eb2864 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_progress-bar.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_progress-bar.less @@ -44,8 +44,8 @@ // --------------------------------------------- .opc-progress-bar { - &:extend(.abs-no-display-s all); &:extend(.abs-reset-list all); + display: none; } } @@ -53,11 +53,12 @@ // Desktop // _____________________________________________ -.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) { +.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { .opc-progress-bar { .css(margin, 0 0 @checkout-progress-bar__margin); counter-reset: i; + display: block; font-size: 0; } From 2314320aa6a7087d83935c8fc8c7443edf161a0c Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Tue, 7 Jul 2015 12:18:30 +0300 Subject: [PATCH 05/23] MAGETWO-39633: All offline payment methods dont work with "Payment from Applicable Countries" setting --- .../Model/ShippingInformationManagement.php | 3 +- .../Payment/Model/Checks/CanUseForCountry.php | 16 +++++++- .../CanUseForCountry/CountryProvider.php | 38 +++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php diff --git a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php index 554caf8aa1c71..2c07db0239885 100644 --- a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php +++ b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php @@ -109,7 +109,6 @@ public function saveAddressInformation( $this->validateQuote($quote); $saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0; - $sameAsBilling = $address->getSameAsBilling() ? 1 : 0; $customerAddressId = $address->getCustomerAddressId(); $this->addressValidator->validate($address); $quote->setShippingAddress($address); @@ -119,7 +118,7 @@ public function saveAddressInformation( $addressData = $this->addressRepository->getById($customerAddressId); $address = $quote->getShippingAddress()->importCustomerAddressData($addressData); } - $address->setSameAsBilling($sameAsBilling); + $address->setSaveInAddressBook($saveInAddressBook); $address->setCollectShippingRates(true); diff --git a/app/code/Magento/Payment/Model/Checks/CanUseForCountry.php b/app/code/Magento/Payment/Model/Checks/CanUseForCountry.php index 46e129662cc78..7490933706825 100644 --- a/app/code/Magento/Payment/Model/Checks/CanUseForCountry.php +++ b/app/code/Magento/Payment/Model/Checks/CanUseForCountry.php @@ -7,9 +7,23 @@ use Magento\Payment\Model\MethodInterface; use Magento\Quote\Model\Quote; +use Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider; class CanUseForCountry implements SpecificationInterface { + /** + * @var CountryProvider + */ + protected $countryProvider; + + /** + * @param CountryProvider $countryProvider + */ + public function __construct(CountryProvider $countryProvider) + { + $this->countryProvider = $countryProvider; + } + /** * Check whether payment method is applicable to quote * @param MethodInterface $paymentMethod @@ -18,6 +32,6 @@ class CanUseForCountry implements SpecificationInterface */ public function isApplicable(MethodInterface $paymentMethod, Quote $quote) { - return $paymentMethod->canUseForCountry($quote->getBillingAddress()->getCountry()); + return $paymentMethod->canUseForCountry($this->countryProvider->getCountry($quote)); } } diff --git a/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php new file mode 100644 index 0000000000000..418173077f1d5 --- /dev/null +++ b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php @@ -0,0 +1,38 @@ +directoryHelper = $directoryHelper; + } + + /** + * Get payment country + * + * @param Quote $quote + * @return int + */ + public function getCountry(Quote $quote) + { + return $quote->isVirtual() + ? $this->directoryHelper->getDefaultCountry() + : $quote->getShippingAddress()->getCountry(); + } +} From d38ec83d217e139d3f7f0def04d54a9dad64c298 Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Tue, 7 Jul 2015 13:16:34 +0300 Subject: [PATCH 06/23] MAGETWO-34039: Zip is marked as required inside "Estimate Shipping and Tax" section on Shopping Cart --- .../Magento/Checkout/view/frontend/web/js/region-updater.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js b/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js index d6cef062b1d50..f4c2213022caf 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js @@ -194,7 +194,7 @@ define([ if (this.options.isZipRequired) { $.inArray(country, this.options.countriesWithOptionalZip) >= 0 ? postcode.removeClass('required-entry').closest('.field').removeClass('required') : - postcode.removeClass('required-entry').closest('.field').addClass('required'); + postcode.addClass('required-entry').closest('.field').addClass('required'); } // Add defaultvalue attribute to state/province select element From 86f6f89a1e0e966dae4620cd7fb699e514123158 Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Tue, 7 Jul 2015 13:41:44 +0300 Subject: [PATCH 07/23] MAGETWO-39618: Text message under e-mail field should disappears if inputted e-mail is registered --- .../Customer/view/frontend/web/template/customer-email.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/template/customer-email.html b/app/code/Magento/Customer/view/frontend/web/template/customer-email.html index 558bb0a5b4d2e..a2159cc764d2a 100644 --- a/app/code/Magento/Customer/view/frontend/web/template/customer-email.html +++ b/app/code/Magento/Customer/view/frontend/web/template/customer-email.html @@ -25,7 +25,7 @@ data-validate="{required:true, 'validate-email':true}" id="customer-email" /> - +
From c0da22e76a9a32c614ea965c0d6ba34b030f5afc Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Tue, 7 Jul 2015 16:13:12 +0300 Subject: [PATCH 08/23] MAGETWO-39514: Cover new code with unit tests --- .../Test/Unit/Model/Cart/ConfigPluginTest.php | 46 ++++++ .../Block/Checkout/TotalsProcessor.php | 2 +- .../Test/Unit/Block/Cart/SidebarTest.php | 155 ++++++++++++++++-- .../Block/Checkout/TotalsProcessorTest.php | 55 +++++++ .../Test/Unit/CustomerData/CartTest.php | 80 +++++++++ .../Test/Unit/Model/CcConfigProviderTest.php | 101 ++++++++++++ 6 files changed, 420 insertions(+), 19 deletions(-) create mode 100644 app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php create mode 100644 app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php create mode 100644 app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php create mode 100644 app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php diff --git a/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php b/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php new file mode 100644 index 0000000000000..2761a141c1768 --- /dev/null +++ b/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php @@ -0,0 +1,46 @@ +configProviderMock = $this->getMock('\Magento\Captcha\Model\Checkout\ConfigProvider', [], [], '', false); + $this->model = new \Magento\Captcha\Model\Cart\ConfigPlugin( + $this->configProviderMock + ); + } + + public function testAfterGetConfig() + { + $resultMock = [ + 'result' => [ + 'data' => 'resultDataMock' + ] + ]; + $configMock = [ + 'config' => [ + 'data' => 'configDataMock' + ] + ]; + $expectedResult = array_merge_recursive($resultMock, $configMock); + $sidebarMock = $this->getMock('\Magento\Checkout\Block\Cart\Sidebar', [], [], '', false); + $this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($configMock); + + $this->assertEquals($expectedResult, $this->model->afterGetConfig($sidebarMock, $resultMock)); + } +} \ No newline at end of file diff --git a/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php b/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php index 65315c2c33e13..40438aaa6e9ff 100644 --- a/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php @@ -43,6 +43,6 @@ public function process($jsLayout) $jsLayout['components']['checkout']['children']['sidebar']['children']['summary'] ['children']['totals']['children'] = $totals; - return array_merge_recursive($jsLayout, $totals); + return $jsLayout; } } diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php index d212eec3a5a7e..07131d91d63c3 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php @@ -10,9 +10,82 @@ class SidebarTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $_objectManager; + /** + * @var \Magento\Checkout\Block\Cart\Sidebar + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilderMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSessionMock; + protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->layoutMock = $this->getMock('\Magento\Framework\View\Layout', [], [], '', false); + $this->checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $this->urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); + $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->viewMock = $this->getMock('\Magento\Catalog\Model\Product\Image\View', [], [], '', false); + $this->scopeConfigMock = $this->getMock( + '\Magento\Framework\App\Config\ScopeConfigInterface', + [], + [], + '', + false + ); + + $contextMock = $this->getMock( + '\Magento\Framework\View\Element\Template\Context', + ['getLayout', 'getUrlBuilder', 'getStoreManager', 'getScopeConfig'], + [], + '', + false + ); + $contextMock->expects($this->once()) + ->method('getLayout') + ->will($this->returnValue($this->layoutMock)); + $contextMock->expects($this->once()) + ->method('getUrlBuilder') + ->will($this->returnValue($this->urlBuilderMock)); + $contextMock->expects($this->once()) + ->method('getStoreManager') + ->will($this->returnValue($this->storeManagerMock)); + $contextMock->expects($this->once()) + ->method('getScopeConfig') + ->will($this->returnValue($this->scopeConfigMock)); + + $this->model = $this->_objectManager->getObject( + 'Magento\Checkout\Block\Cart\Sidebar', + ['context' => $contextMock, 'imageView' => $this->viewMock, 'checkoutSession' => $this->checkoutSessionMock] + ); } public function testGetTotalsHtml() @@ -27,30 +100,76 @@ public function testGetTotalsHtml() ->method('toHtml') ->will($this->returnValue($totalsHtml)); - $layoutMock = $this->getMockBuilder('\Magento\Framework\View\Layout') - ->disableOriginalConstructor() - ->getMock(); - - $layoutMock->expects($this->once()) + $this->layoutMock->expects($this->once()) ->method('getBlock') ->with('checkout.cart.minicart.totals') ->will($this->returnValue($totalsBlockMock)); - $contextMock = $this->getMockBuilder('\Magento\Framework\View\Element\Template\Context') - ->disableOriginalConstructor() - ->setMethods(['getLayout']) - ->getMock(); + $this->assertEquals($totalsHtml, $this->model->getTotalsHtml()); + } - $contextMock->expects($this->once()) - ->method('getLayout') - ->will($this->returnValue($layoutMock)); + public function testGetConfig() + { + $storeMock = $this->getMock('\Magento\Store\Model\Store', [], [], '', false); - /** @var \Magento\Checkout\Block\Cart\Sidebar $sidebarBlock */ - $sidebarBlock = $this->_objectManager->getObject( - 'Magento\Checkout\Block\Cart\Sidebar', - ['context' => $contextMock] - ); + $shoppingCartUrl = 'http://url.com/cart'; + $checkoutUrl = 'http://url.com/checkout'; + $updateItemQtyUrl = 'http://url.com/updateItemQty'; + $removeItemUrl = 'http://url.com/removeItem'; + $customerRegisterUrl = 'http://url.com/register'; + $customerForgotPasswordUrl = 'http://url.com/forgot'; + $baseUrl = 'http://url.com/'; + $imageTemplate = 'Magento_Catalog/product/image_with_borders'; + + $expectedResult = [ + 'shoppingCartUrl' => $shoppingCartUrl, + 'checkoutUrl' => $checkoutUrl, + 'updateItemQtyUrl' => $updateItemQtyUrl, + 'removeItemUrl' => $removeItemUrl, + 'imageTemplate' => $imageTemplate, + 'customerRegisterUrl' => $customerRegisterUrl, + 'customerForgotPasswordUrl' => $customerForgotPasswordUrl, + 'baseUrl' => $baseUrl + ]; + + $valueMap = [ + ['checkout/cart', [], $shoppingCartUrl], + ['checkout', [], $checkoutUrl], + ['checkout/sidebar/updateItemQty', [], $updateItemQtyUrl], + ['checkout/sidebar/removeItem', [], $removeItemUrl], + ['customer/account/create', [], $customerRegisterUrl], + ['customer/account/forgotpassword', [], $customerForgotPasswordUrl] + ]; + + $this->urlBuilderMock->expects($this->exactly(6)) + ->method('getUrl') + ->willReturnMap($valueMap); + $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); + $this->viewMock->expects($this->once())->method('isWhiteBorders')->willReturn(false); + + $this->assertEquals($expectedResult, $this->model->getConfig()); + } + + public function testGetIsNeedToDisplaySideBar() + { + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with( + \Magento\Checkout\Block\Cart\Sidebar::XML_PATH_CHECKOUT_SIDEBAR_DISPLAY, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + )->willReturn(true); + + $this->assertTrue($this->model->getIsNeedToDisplaySideBar()); + } + + public function testGetTotalsCache() + { + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $totalsMock = ['totals']; + $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); + $quoteMock->expects($this->once())->method('getTotals')->willReturn($totalsMock); - $this->assertEquals($totalsHtml, $sidebarBlock->getTotalsHtml()); + $this->assertEquals($totalsMock, $this->model->getTotalsCache()); } } diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php new file mode 100644 index 0000000000000..5d276d56991fc --- /dev/null +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php @@ -0,0 +1,55 @@ +scopeConfigMock = $this->getMock( + '\Magento\Framework\App\Config\ScopeConfigInterface', + [], + [], + '', + false + ); + + $this->model = new \Magento\Checkout\Block\Checkout\TotalsProcessor($this->scopeConfigMock); + } + + public function testProcess() + { + $jsLayout['components']['checkout']['children']['sidebar']['children']['summary'] + ['children']['totals']['children'] = [ + 'sub-total' => [], + 'grand-total' => [], + 'non-existant-total' => null + ]; + $expectedResult['components']['checkout']['children']['sidebar']['children']['summary'] + ['children']['totals']['children'] = [ + 'sub-total' => ['sortOrder' => 10], + 'grand-total' => ['sortOrder' => 20], + 'non-existant-total' => null + ]; + $configData = ['sub_total' => 10, 'grand_total' => 20]; + + $this->scopeConfigMock->expects($this->once())->method('getValue')->with('sales/totals_sort') + ->willReturn($configData); + + $this->assertEquals($expectedResult, $this->model->process($jsLayout)); + } +} diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php new file mode 100644 index 0000000000000..0be9fef0be532 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php @@ -0,0 +1,80 @@ +checkoutSessionMock = $this->getMock('\Magento\Checkout\Model\Session', [], [], '', false); + $this->catalogUrlMock = $this->getMock('\Magento\Catalog\Model\Resource\Url', [], [], '', false); + $this->checkoutCartMock = $this->getMock('\Magento\Checkout\Model\Cart', [], [], '', false); + $this->checkoutHelperMock = $this->getMock('\Magento\Checkout\Helper\Data', [], [], '', false); + $this->layoutMock = $this->getMock('\Magento\Framework\View\LayoutInterface', [], [], '', false); + $this->itemPoolInterfaceMock = $this->getMock( + '\Magento\Checkout\CustomerData\ItemPoolInterface', + [], + [], + '', + false + ); + + $this->model = new \Magento\Checkout\CustomerData\Cart( + $this->checkoutSessionMock, + $this->catalogUrlMock, + $this->checkoutCartMock, + $this->checkoutHelperMock, + $this->itemPoolInterfaceMock, + $this->layoutMock + ); + } + + public function testIsGuestCheckoutAllowed() + { + $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); + $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); + $this->checkoutHelperMock->expects($this->once())->method('isAllowedGuestCheckout')->with($quoteMock) + ->willReturn(true); + + $this->assertTrue($this->model->isGuestCheckoutAllowed()); + } +} diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php new file mode 100644 index 0000000000000..217ac20644e7e --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php @@ -0,0 +1,101 @@ +ccConfigMock = $this->getMock('\Magento\Payment\Model\CcConfig', [], [], '', false); + $this->assetSourceMock = $this->getMock('\Magento\Framework\View\Asset\Source', [], [], '', false); + $this->model = new \Magento\Payment\Model\CcConfigProvider( + $this->ccConfigMock, + $this->assetSourceMock + ); + } + + public function testGetConfig() + { + $imagesDirectoryPath = __DIR__ . '/../../../view/base/web/images/cc/'; + $expectedResult = [ + 'payment' => [ + 'ccform' => [ + 'icons' => [ + 'vi' => [ + 'url' => 'http://cc.card/vi.png', + 'width' => getimagesize($imagesDirectoryPath . 'vi.png')[0], + 'height' => getimagesize($imagesDirectoryPath . 'vi.png')[1] + ], + 'ae' => [ + 'url' => 'http://cc.card/ae.png', + 'width' => getimagesize($imagesDirectoryPath . 'ae.png')[0], + 'height' => getimagesize($imagesDirectoryPath . 'ae.png')[1] + ] + ] + ] + ] + ]; + + $ccAvailableTypesMock = [ + 'vi' => [ + 'fileId' => 'Magento_Payment::images/cc/vi.png', + 'path' => $imagesDirectoryPath . 'vi.png', + 'url' => 'http://cc.card/vi.png' + ], + 'ae' => [ + 'fileId' => 'Magento_Payment::images/cc/ae.png', + 'path' => $imagesDirectoryPath . 'ae.png', + 'url' => 'http://cc.card/ae.png' + ] + ]; + $assetMock = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); + + $this->ccConfigMock->expects($this->once())->method('getCcAvailableTypes')->willReturn($ccAvailableTypesMock); + + $this->ccConfigMock->expects($this->atLeastOnce()) + ->method('createAsset') + ->withConsecutive( + [$ccAvailableTypesMock['vi']['fileId']], + [$ccAvailableTypesMock['ae']['fileId']] + )->willReturn($assetMock); + $this->assetSourceMock->expects($this->atLeastOnce()) + ->method('findRelativeSourceFilePath') + ->with($assetMock) + ->willReturnOnConsecutiveCalls( + $ccAvailableTypesMock['vi']['path'], + $ccAvailableTypesMock['ae']['path'] + ); + $assetMock->expects($this->atLeastOnce()) + ->method('getSourceFile') + ->willReturnOnConsecutiveCalls( + $ccAvailableTypesMock['vi']['path'], + $ccAvailableTypesMock['ae']['path'] + ); + $assetMock->expects($this->atLeastOnce()) + ->method('getUrl') + ->willReturnOnConsecutiveCalls( + $ccAvailableTypesMock['vi']['url'], + $ccAvailableTypesMock['ae']['url'] + ); + + $this->assertEquals($expectedResult, $this->model->getConfig()); + } +} From 009b00fbbfc8af4569ac07c01f15492ae64c0245 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 7 Jul 2015 16:22:16 +0300 Subject: [PATCH 09/23] MAGETWO-39742: Two customer addresses are saved instead of one during checkout --- .../frontend/web/js/action/select-billing-address.js | 12 ++++++++++-- .../web/js/action/select-shipping-address.js | 12 +++++++----- .../view/frontend/web/js/view/billing-address.js | 12 ++++++++++-- .../view/frontend/web/js/model/customer/address.js | 3 +++ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js index da290fc1aa214..478dc2f29e4b4 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js @@ -5,12 +5,20 @@ /*global define*/ define( [ + 'jquery', '../model/quote' ], - function(quote) { + function($, quote) { "use strict"; return function(billingAddress) { - quote.billingAddress(billingAddress); + var address = null; + if (billingAddress.getCacheKey() == quote.shippingAddress().getCacheKey()) { + address = $.extend({}, billingAddress); + address.save_in_address_book = false; + } else { + address = billingAddress; + } + quote.billingAddress(address); }; } ); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js index a8d1e6d38be27..db5bd93b275a6 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js @@ -4,11 +4,13 @@ */ /*global define*/ define( - ['../model/quote', - 'Magento_Checkout/js/model/shipping-rate-service' + [ + '../model/quote', + 'Magento_Checkout/js/model/shipping-rate-service', + 'Magento_Checkout/js/action/select-billing-address' ], - function(quote, shippingRateService) { - "use strict"; + function(quote, shippingRateService, selectBillingAddress) { + 'use strict'; quote.shippingAddress.subscribe(function () { shippingRateService.getRates(quote.shippingAddress()) }); @@ -16,7 +18,7 @@ define( quote.shippingAddress(shippingAddress); //set billing address same as shipping by default if it is not empty if (shippingAddress.countryId != undefined && shippingAddress.canUseForBilling()) { - quote.billingAddress(shippingAddress); + selectBillingAddress(quote.shippingAddress()); } }; } diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 945cd2802754e..d0b56b424294c 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -50,10 +50,16 @@ define( isAddressFormVisible: !customer.isLoggedIn() || addressOptions.length == 1, isAddressSameAsShipping: false }); + quote.billingAddress.subscribe(function(newAddress) { - this.isAddressSameAsShipping(newAddress == quote.shippingAddress() && !quote.isVirtual()); + this.isAddressSameAsShipping( + newAddress != null + && newAddress.getCacheKey() == quote.shippingAddress().getCacheKey() + && !quote.isVirtual() + ); this.isAddressDetailsVisible(true); }, this); + return this; }, @@ -117,7 +123,9 @@ define( if (quote.billingAddress()) { // restore 'Same As Shipping' checkbox state this.isAddressSameAsShipping( - !quote.isVirtual() && (quote.shippingAddress() == quote.billingAddress()) + quote.billingAddress() != null + && quote.billingAddress().getCacheKey() == quote.shippingAddress().getCacheKey() + && !quote.isVirtual() ); this.isAddressDetailsVisible(true); } diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js index c3f656411450d..b10800641c443 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js +++ b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js @@ -47,6 +47,9 @@ define([], function() { getKey: function() { return this.getType() + this.customerAddressId; }, + getCacheKey: function() { + return this.getKey(); + }, isEditable: function() { return false; }, From be5803a45e41762a05c0459273f700b797a62415 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 7 Jul 2015 17:17:00 +0300 Subject: [PATCH 10/23] MAGETWO-39742: Two customer addresses are saved instead of one during checkout --fixes after CR --- .../Checkout/view/frontend/web/js/view/billing-address.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index d0b56b424294c..95f20afa7264e 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -54,8 +54,8 @@ define( quote.billingAddress.subscribe(function(newAddress) { this.isAddressSameAsShipping( newAddress != null - && newAddress.getCacheKey() == quote.shippingAddress().getCacheKey() - && !quote.isVirtual() + && newAddress.getCacheKey() == quote.shippingAddress().getCacheKey() + && !quote.isVirtual() ); this.isAddressDetailsVisible(true); }, this); @@ -124,8 +124,8 @@ define( // restore 'Same As Shipping' checkbox state this.isAddressSameAsShipping( quote.billingAddress() != null - && quote.billingAddress().getCacheKey() == quote.shippingAddress().getCacheKey() - && !quote.isVirtual() + && quote.billingAddress().getCacheKey() == quote.shippingAddress().getCacheKey() + && !quote.isVirtual() ); this.isAddressDetailsVisible(true); } From 9e3f16adc27ec9f23d396f7821ab4bc19ef39892 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 7 Jul 2015 20:22:40 +0300 Subject: [PATCH 11/23] MAGETWO-38644: Output data Estimated Total and Cart Items Count on Checkout CR changes --- .../Checkout/view/frontend/layout/checkout_index_index.xml | 3 +++ .../Magento/Checkout/view/frontend/web/js/view/estimation.js | 3 +-- .../Checkout/view/frontend/web/js/view/shipping-information.js | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml index 2801b790a8e99..e8a974ee88cd5 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml @@ -55,6 +55,9 @@ estimation Magento_Checkout/estimation + + checkout.sidebar +
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js index 27c89e2b6566a..169da99995b75 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js @@ -10,8 +10,7 @@ define( 'Magento_Checkout/js/model/quote', 'Magento_Catalog/js/price-utils', 'Magento_Checkout/js/model/totals', - 'Magento_Checkout/js/model/sidebar', - 'Magento_Checkout/js/view/sidebar' + 'Magento_Checkout/js/model/sidebar' ], function (Component, quote, priceUtils, totals, sidebarModel) { 'use strict'; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js index 678457699df6b..c5b863d51da64 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js @@ -11,8 +11,7 @@ define( 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/shipping-service', 'Magento_Checkout/js/model/step-navigator', - 'Magento_Checkout/js/model/sidebar', - 'Magento_Checkout/js/view/sidebar' + 'Magento_Checkout/js/model/sidebar' ], function($, Component, quote, shippingService, stepNavigator, sidebarModel) { 'use strict'; From e29db3d68a933e3805982192af09ecfe1b3eb323 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Tue, 7 Jul 2015 22:12:23 +0300 Subject: [PATCH 12/23] MAGETWO-38644: Output data Estimated Total and Cart Items Count on Checkout minor fix --- .../Magento/Checkout/view/frontend/web/js/view/estimation.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js index 169da99995b75..76e34d4cbf520 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js @@ -1,9 +1,7 @@ - define( [ 'uiComponent', From dfd187a6dbf2629010c25804b1639b2af07261c5 Mon Sep 17 00:00:00 2001 From: Alex Akimov Date: Wed, 8 Jul 2015 11:01:54 +0300 Subject: [PATCH 13/23] MAGETWO-39765: Integration tests failing in Checkout module - Removed integration tests that covered deprecated code; --- .../Checkout/Controller/OnepageTest.php | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php deleted file mode 100644 index 567ad6ec03b14..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/OnepageTest.php +++ /dev/null @@ -1,43 +0,0 @@ -create('Magento\Quote\Model\Quote'); - $quote->load('test01', 'reserved_order_id'); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Checkout\Model\Session' - )->setQuoteId( - $quote->getId() - ); - } - - public function testSaveOrderActionWithoutFormKey() - { - $this->dispatch('checkout/onepage/saveOrder'); - $this->assertRedirect($this->stringContains('checkout/onepage')); - } - - public function testSaveOrderActionWithFormKey() - { - $formKey = $this->_objectManager->get('Magento\Framework\Data\Form\FormKey'); - $this->getRequest()->setParam('form_key', $formKey->getFormKey()); - $this->dispatch('checkout/onepage/saveOrder'); - $html = $this->getResponse()->getBody(); - $this->assertEquals( - '{"success":false,"error":true,"error_messages":"Please specify a shipping method."}', - $html, - $html - ); - } -} From 25fed0e5f0808b4e85a24f73c2abc68b527dba8e Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Wed, 8 Jul 2015 11:34:38 +0300 Subject: [PATCH 14/23] MAGETWO-39633: All offline payment methods dont work with "Payment from Applicable Countries" setting --- .../Model/Checks/CanUseForCountryTest.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php index c9f1407a98349..2df67ab234dd3 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountryTest.php @@ -15,6 +15,11 @@ class CanUseForCountryTest extends \PHPUnit_Framework_TestCase */ const EXPECTED_COUNTRY_ID = 1; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $countryProvider; + /** * @var CanUseForCountry */ @@ -22,7 +27,15 @@ class CanUseForCountryTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->_model = new CanUseForCountry(); + $this->countryProvider = $this->getMock( + 'Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider', + [], + [], + '', + false, + false + ); + $this->_model = new CanUseForCountry($this->countryProvider); } /** @@ -34,13 +47,6 @@ public function testIsApplicable($expectation) $quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')->disableOriginalConstructor()->setMethods( [] )->getMock(); - $billingAddressMock = $this->getMockBuilder( - 'Magento\Quote\Model\Quote\Address' - )->disableOriginalConstructor()->setMethods([])->getMock(); - $billingAddressMock->expects($this->once())->method('getCountry')->will( - $this->returnValue(self::EXPECTED_COUNTRY_ID) - ); - $quoteMock->expects($this->once())->method('getBillingAddress')->will($this->returnValue($billingAddressMock)); $paymentMethod = $this->getMockBuilder( '\Magento\Payment\Model\MethodInterface' @@ -48,6 +54,7 @@ public function testIsApplicable($expectation) $paymentMethod->expects($this->once())->method('canUseForCountry')->with( self::EXPECTED_COUNTRY_ID )->will($this->returnValue($expectation)); + $this->countryProvider->expects($this->once())->method('getCountry')->willReturn(self::EXPECTED_COUNTRY_ID); $this->assertEquals($expectation, $this->_model->isApplicable($paymentMethod, $quoteMock)); } From 6aab4f108abbffb140c2412dc07815ac08d48661 Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Wed, 8 Jul 2015 11:50:15 +0300 Subject: [PATCH 15/23] MAGETWO-39633: All offline payment methods dont work with "Payment from Applicable Countries" setting --- .../Test/Unit/Model/Cart/ConfigPluginTest.php | 2 +- .../CanUseForCountry/CountryProvider.php | 2 +- .../CanUseForCountry/CountryProviderTest.php | 46 +++++++++++++++++++ app/code/Magento/Payment/composer.json | 1 + 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php diff --git a/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php b/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php index 2761a141c1768..be94382ea2ab3 100644 --- a/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php +++ b/app/code/Magento/Captcha/Test/Unit/Model/Cart/ConfigPluginTest.php @@ -43,4 +43,4 @@ public function testAfterGetConfig() $this->assertEquals($expectedResult, $this->model->afterGetConfig($sidebarMock, $resultMock)); } -} \ No newline at end of file +} diff --git a/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php index 418173077f1d5..8bbdbef28307a 100644 --- a/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php +++ b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php @@ -6,7 +6,7 @@ namespace Magento\Payment\Model\Checks\CanUseForCountry; use Magento\Quote\Model\Quote; -use \Magento\Directory\Helper\Data as DirectoryHelper; +use Magento\Directory\Helper\Data as DirectoryHelper; class CountryProvider { diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php new file mode 100644 index 0000000000000..85973e644616c --- /dev/null +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -0,0 +1,46 @@ +directoryMock = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false, false); + $this->model = new CountryProvider($this->directoryMock); + } + + public function testGetCountryForNonVirtualQuote() + { + $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock->expects($this->once())->method('isVirtual')->willReturn(false); + $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock->expects($this->once())->method('getCountry')->will($this->returnValue(1)); + $quoteMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($addressMock)); + $this->assertEquals(1, $this->model->getCountry($quoteMock)); + } + + public function testGetCountryForVirtualQuote() + { + $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); + $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock->expects($this->never())->method('getCountry'); + $quoteMock->expects($this->never())->method('getShippingAddress'); + $this->directoryMock->expects($this->once())->method('getDefaultCountry')->willReturn(10); + $this->assertEquals(10, $this->model->getCountry($quoteMock)); + } +} diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 4f7a7f707bb82..b72ba192b4d49 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -8,6 +8,7 @@ "magento/module-sales": "0.74.0-beta16", "magento/module-checkout": "0.74.0-beta16", "magento/module-quote": "0.74.0-beta16", + "magento/module-directory": "0.74.0-beta16", "magento/framework": "0.74.0-beta16", "magento/magento-composer-installer": "*" }, From bb729896457478aedf970a7c22c52201459b30e6 Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Wed, 8 Jul 2015 15:35:09 +0300 Subject: [PATCH 16/23] MAGETWO-36978: [Folks] Bugs fixing S71 integrity test fix --- .../Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index 85973e644616c..a3b8bbcf60424 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Payment\Model\Checks\CanUseForCountry; +namespace Magento\Payment\Test\Unit\Model\Checks\CanUseForCountry; class CountryProviderTest extends \PHPUnit_Framework_TestCase { From aae003f311b2e0d05ddcc24ec665404d9a5bfab4 Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Wed, 8 Jul 2015 12:57:37 +0300 Subject: [PATCH 17/23] MAGETWO-39633: All offline payment methods dont work with "Payment from Applicable Countries" setting --- .../Model/Checks/CanUseForCountry/CountryProviderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index a3b8bbcf60424..13f1ad7d41451 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -8,7 +8,7 @@ class CountryProviderTest extends \PHPUnit_Framework_TestCase { /** - * @var CountryProvider + * @var \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider */ protected $model; @@ -20,7 +20,7 @@ class CountryProviderTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->directoryMock = $this->getMock('Magento\Directory\Helper\Data', [], [], '', false, false); - $this->model = new CountryProvider($this->directoryMock); + $this->model = new \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider($this->directoryMock); } public function testGetCountryForNonVirtualQuote() From 3a18986e420dc68b84c4bfde13cabbd5e740243c Mon Sep 17 00:00:00 2001 From: Serhiy Shkolyarenko Date: Wed, 8 Jul 2015 16:00:50 +0300 Subject: [PATCH 18/23] MAGETWO-36978: [Folks] Bugs fixing S71 minor fix --- .../Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index 13f1ad7d41451..8c12b1c89acc8 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Payment\Test\Unit\Model\Checks\CanUseForCountry; +use \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider; + class CountryProviderTest extends \PHPUnit_Framework_TestCase { /** From 6d648f1a2e48f8a67fe8368a85122e5fc4eacfa3 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Mon, 6 Jul 2015 11:10:41 +0300 Subject: [PATCH 19/23] MAGETWO-39108: Shopping Cart becomes empty if Customer updates the item to be the same as already existent in Shopping Cart --- app/code/Magento/Quote/Model/Quote/Item/Processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item/Processor.php b/app/code/Magento/Quote/Model/Quote/Item/Processor.php index 9c0894a785ef5..471e7ef9a36ce 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Processor.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Processor.php @@ -94,7 +94,7 @@ public function prepare(Item $item, Object $request, Product $candidate) /** * We specify qty after we know about parent (for stock) */ - if ($request->getResetCount()) { + if ($request->getResetCount() && !$candidate->getStickWithinParent() && $item->getId() === $request->getId()) { $item->setData(CartItemInterface::KEY_QTY, 0); } $item->addQty($candidate->getCartQty()); From bb997b14041c9ff9fb7b8dbebe675fa791c6e4d2 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Mon, 6 Jul 2015 16:06:29 +0300 Subject: [PATCH 20/23] MAGETWO-39108: Shopping Cart becomes empty if Customer updates the item to be the same as already existent in Shopping Cart --- .../Quote/Model/Quote/Item/Processor.php | 2 +- .../Unit/Model/Quote/Item/ProcessorTest.php | 161 ++++++++++++++++-- 2 files changed, 150 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item/Processor.php b/app/code/Magento/Quote/Model/Quote/Item/Processor.php index 471e7ef9a36ce..ad17f5a8ea5be 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Processor.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Processor.php @@ -94,7 +94,7 @@ public function prepare(Item $item, Object $request, Product $candidate) /** * We specify qty after we know about parent (for stock) */ - if ($request->getResetCount() && !$candidate->getStickWithinParent() && $item->getId() === $request->getId()) { + if ($request->getResetCount() && !$candidate->getStickWithinParent() && $item->getId() == $request->getId()) { $item->setData(CartItemInterface::KEY_QTY, 0); } $item->addQty($candidate->getCartQty()); diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php index b27d2ca465a3e..84864eab6296e 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/ProcessorTest.php @@ -72,7 +72,16 @@ protected function setUp() $this->itemMock = $this->getMock( 'Magento\Quote\Model\Quote\Item', - ['getId', 'setOptions', '__wakeup', 'setProduct', 'addQty', 'setCustomPrice', 'setOriginalCustomPrice'], + [ + 'getId', + 'setOptions', + '__wakeup', + 'setProduct', + 'addQty', + 'setCustomPrice', + 'setOriginalCustomPrice', + 'setData' + ], [], '', false @@ -109,7 +118,7 @@ protected function setUp() $this->productMock = $this->getMock( 'Magento\Catalog\Model\Product', - ['getCustomOptions', '__wakeup', 'getParentProductId', 'getCartQty'], + ['getCustomOptions', '__wakeup', 'getParentProductId', 'getCartQty', 'getStickWithinParent'], [], '', false @@ -148,8 +157,12 @@ public function testInitWithQtyModification() ->will($this->returnValue($itemId)); $this->itemMock->expects($this->any()) ->method('setData') - ->with($this->equalTo('qty'), $this->equalTo(0)); - + ->willReturnMap( + [ + ['store_id', $storeId], + ['qty', 0], + ] + ); $this->storeMock->expects($this->any()) ->method('getId') @@ -177,7 +190,6 @@ public function testInitWithoutModification() ->method('getParentProductId') ->will($this->returnValue(true)); - $this->itemMock->expects($this->never())->method('setOptions'); $this->itemMock->expects($this->never())->method('setProduct'); @@ -185,7 +197,13 @@ public function testInitWithoutModification() ->method('getId') ->will($this->returnValue($itemId)); - $this->itemMock->expects($this->never())->method('setData'); + $this->itemMock->expects($this->any()) + ->method('setData') + ->willReturnMap( + [ + ['store_id', $storeId], + ] + ); $this->storeMock->expects($this->any()) ->method('getId') @@ -222,7 +240,13 @@ public function testInitWithoutModificationAdminhtmlAreaCode() ->method('getId') ->will($this->returnValue($itemId)); - $this->itemMock->expects($this->never())->method('setData'); + $this->itemMock->expects($this->any()) + ->method('setData') + ->willReturnMap( + [ + ['store_id', $storeId], + ] + ); $this->storeMock->expects($this->any()) ->method('getId') @@ -238,58 +262,171 @@ public function testPrepare() { $qty = 3000000000; $customPrice = 400000000; + $itemId = 1; + $requestItemId = 1; $this->productMock->expects($this->any()) ->method('getCartQty') ->will($this->returnValue($qty)); + $this->productMock->expects($this->any()) + ->method('getStickWithinParent') + ->will($this->returnValue(false)); - $this->itemMock->expects($this->any()) + $this->itemMock->expects($this->once()) ->method('addQty') ->with($qty); + $this->itemMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($itemId)); + $this->itemMock->expects($this->never()) + ->method('setData'); $this->objectMock->expects($this->any()) ->method('getCustomPrice') ->will($this->returnValue($customPrice)); + $this->objectMock->expects($this->any()) + ->method('getResetCount') + ->will($this->returnValue(false)); + $this->objectMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($requestItemId)); + + $this->itemMock->expects($this->once()) + ->method('setCustomPrice') + ->will($this->returnValue($customPrice)); + $this->itemMock->expects($this->once()) + ->method('setOriginalCustomPrice') + ->will($this->returnValue($customPrice)); + $this->processor->prepare($this->itemMock, $this->objectMock, $this->productMock); + } + + public function testPrepareWithResetCountAndStick() + { + $qty = 3000000000; + $customPrice = 400000000; + $itemId = 1; + $requestItemId = 1; + + $this->productMock->expects($this->any()) + ->method('getCartQty') + ->will($this->returnValue($qty)); + $this->productMock->expects($this->any()) + ->method('getStickWithinParent') + ->will($this->returnValue(true)); + + $this->itemMock->expects($this->once()) + ->method('addQty') + ->with($qty); $this->itemMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($itemId)); + $this->itemMock->expects($this->never()) + ->method('setData'); + + $this->objectMock->expects($this->any()) + ->method('getCustomPrice') + ->will($this->returnValue($customPrice)); + $this->objectMock->expects($this->any()) + ->method('getResetCount') + ->will($this->returnValue(true)); + $this->objectMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($requestItemId)); + + $this->itemMock->expects($this->once()) ->method('setCustomPrice') ->will($this->returnValue($customPrice)); + $this->itemMock->expects($this->once()) + ->method('setOriginalCustomPrice') + ->will($this->returnValue($customPrice)); + + $this->processor->prepare($this->itemMock, $this->objectMock, $this->productMock); + } + + public function testPrepareWithResetCountAndNotStickAndOtherItemId() + { + $qty = 3000000000; + $customPrice = 400000000; + $itemId = 1; + $requestItemId = 2; + + $this->productMock->expects($this->any()) + ->method('getCartQty') + ->will($this->returnValue($qty)); + $this->productMock->expects($this->any()) + ->method('getStickWithinParent') + ->will($this->returnValue(false)); + + $this->itemMock->expects($this->once()) + ->method('addQty') + ->with($qty); $this->itemMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($itemId)); + $this->itemMock->expects($this->never()) + ->method('setData'); + + $this->objectMock->expects($this->any()) + ->method('getCustomPrice') + ->will($this->returnValue($customPrice)); + $this->objectMock->expects($this->any()) + ->method('getResetCount') + ->will($this->returnValue(true)); + $this->objectMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($requestItemId)); + + $this->itemMock->expects($this->once()) + ->method('setCustomPrice') + ->will($this->returnValue($customPrice)); + $this->itemMock->expects($this->once()) ->method('setOriginalCustomPrice') ->will($this->returnValue($customPrice)); $this->processor->prepare($this->itemMock, $this->objectMock, $this->productMock); } - public function testPrepareResetCount() + public function testPrepareWithResetCountAndNotStickAndSameItemId() { $qty = 3000000000; $customPrice = 400000000; + $itemId = 1; + $requestItemId = 1; $this->objectMock->expects($this->any()) ->method('getResetCount') ->will($this->returnValue(true)); $this->itemMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($itemId)); + $this->itemMock->expects($this->once()) ->method('setData') ->with(CartItemInterface::KEY_QTY, 0); $this->productMock->expects($this->any()) ->method('getCartQty') ->will($this->returnValue($qty)); + $this->productMock->expects($this->any()) + ->method('getStickWithinParent') + ->will($this->returnValue(false)); - $this->itemMock->expects($this->any()) + $this->itemMock->expects($this->once()) ->method('addQty') ->with($qty); $this->objectMock->expects($this->any()) ->method('getCustomPrice') ->will($this->returnValue($customPrice)); + $this->objectMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue($requestItemId)); - $this->itemMock->expects($this->any()) + $this->itemMock->expects($this->once()) ->method('setCustomPrice') ->will($this->returnValue($customPrice)); - $this->itemMock->expects($this->any()) + $this->itemMock->expects($this->once()) ->method('setOriginalCustomPrice') ->will($this->returnValue($customPrice)); From e1f9d514443481e6704493053c7752793c9dab25 Mon Sep 17 00:00:00 2001 From: Andriy Nasinnyk Date: Mon, 6 Jul 2015 17:58:50 +0300 Subject: [PATCH 21/23] MAGETWO-39614: Error after customer logout if he matched customer segment with product from category is viewed condition --- app/code/Magento/Reports/Model/Event/Observer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Reports/Model/Event/Observer.php b/app/code/Magento/Reports/Model/Event/Observer.php index cde42e07e9f59..560e58b337bf6 100644 --- a/app/code/Magento/Reports/Model/Event/Observer.php +++ b/app/code/Magento/Reports/Model/Event/Observer.php @@ -151,7 +151,7 @@ public function catalogProductView(\Magento\Framework\Event\Observer $observer) $productId = $observer->getEvent()->getProduct()->getId(); $viewData['product_id'] = $productId; - + $viewData['store_id'] = $this->_storeManager->getStore()->getId(); if ($this->_customerSession->isLoggedIn()) { $viewData['customer_id'] = $this->_customerSession->getCustomerId(); } else { From 22441e429763f717aec4247e24ba32ff9a539b8b Mon Sep 17 00:00:00 2001 From: Andriy Nasinnyk Date: Tue, 7 Jul 2015 12:09:00 +0300 Subject: [PATCH 22/23] MAGETWO-39614: Error after customer logout if he matched customer segment with product from category is viewed condition --- .../Magento/Reports/Test/Unit/Model/Event/ObserverTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php b/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php index 7e53522ac6680..f1ecde466b1d9 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/Event/ObserverTest.php @@ -85,7 +85,6 @@ public function setUp() /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject $storeManager */ $storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); - $this->storeMock = $this->getMockBuilder('\Magento\Store\Model\Store') ->disableOriginalConstructor()->getMock(); @@ -128,7 +127,8 @@ public function testCatalogProductViewCustomer() $storeId = 1; $expectedViewedData = [ 'product_id' => $productId, - 'customer_id' => $customerId + 'customer_id' => $customerId, + 'store_id' => $storeId, ]; $expectedEventData = [ @@ -160,7 +160,8 @@ public function testCatalogProductViewVisitor() $storeId = 1; $expectedViewedData = [ 'product_id' => $productId, - 'visitor_id' => $visitorId + 'visitor_id' => $visitorId, + 'store_id' => $storeId, ]; $expectedEventData = [ From f05cacff9812b5a451abca6a6106a97c9a5f9b53 Mon Sep 17 00:00:00 2001 From: Olexii Korshenko Date: Wed, 8 Jul 2015 13:13:53 +0300 Subject: [PATCH 23/23] MAGETWO-39633: All offline payment methods dont work with "Payment from Applicable Countries" setting --- .../Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index 8c12b1c89acc8..13f1ad7d41451 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -5,8 +5,6 @@ */ namespace Magento\Payment\Test\Unit\Model\Checks\CanUseForCountry; -use \Magento\Payment\Model\Checks\CanUseForCountry\CountryProvider; - class CountryProviderTest extends \PHPUnit_Framework_TestCase { /**