diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 1dfbf18ae773d..12a4d4d138f53 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -155,8 +155,9 @@ public function getQuote() if ($this->getStoreId()) { if (!$this->getQuoteId()) { $this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId()); + $this->_quote->setIsActive(false); $this->_quote->setStoreId($this->getStoreId()); - + $this->quoteRepository->save($this->_quote); $this->setQuoteId($this->_quote->getId()); $this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index b39e6610b9dbe..00bfe1a4f9419 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -343,6 +343,7 @@ public function testGetQuoteWithoutQuoteId() '', false ); + $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock); $cartInterfaceMock->expects($this->once()) ->method('setCustomerGroupId') @@ -357,7 +358,6 @@ public function testGetQuoteWithoutQuoteId() $quoteMock->expects($this->once()) ->method('setIsSuperMode') ->with(true); - $this->assertEquals($quoteMock, $this->quote->getQuote()); } diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml index cae13fc26cc69..d7fae5232f456 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml @@ -51,6 +51,7 @@ require([ showHour: false, showMinute: false, serverTimezoneSeconds: getStoreTimestamp(); ?>, + serverTimezoneOffset: getTimezoneOffsetSeconds(); ?>, yearRange: 'getYearRange() ?>' } }); diff --git a/app/code/Magento/Braintree/Controller/Paypal/Review.php b/app/code/Magento/Braintree/Controller/Paypal/Review.php index b2b95f7897856..1b6c3a3ab5a91 100644 --- a/app/code/Magento/Braintree/Controller/Paypal/Review.php +++ b/app/code/Magento/Braintree/Controller/Paypal/Review.php @@ -10,6 +10,7 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Braintree\Gateway\Config\PayPal\Config; use Magento\Braintree\Model\Paypal\Helper\QuoteUpdater; +use Magento\Framework\Exception\LocalizedException; /** * Class Review @@ -21,6 +22,11 @@ class Review extends AbstractAction */ private $quoteUpdater; + /** + * @var string + */ + private static $paymentMethodNonce = 'payment_method_nonce'; + /** * Constructor * @@ -52,13 +58,16 @@ public function execute() try { $this->validateQuote($quote); - $this->validateRequestData($requestData); - $this->quoteUpdater->execute( - $requestData['nonce'], - $requestData['details'], - $quote - ); + if ($this->validateRequestData($requestData)) { + $this->quoteUpdater->execute( + $requestData['nonce'], + $requestData['details'], + $quote + ); + } elseif (!$quote->getPayment()->getAdditionalInformation(self::$paymentMethodNonce)) { + throw new LocalizedException(__('We can\'t initialize checkout.')); + } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); @@ -82,13 +91,10 @@ public function execute() /** * @param array $requestData - * @return void - * @throws \InvalidArgumentException + * @return boolean */ private function validateRequestData(array $requestData) { - if (empty($requestData['nonce']) || empty($requestData['details'])) { - throw new \InvalidArgumentException('Data of request cannot be empty.'); - } + return !empty($requestData['nonce']) && !empty($requestData['details']); } } diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index 4f1c053d31fba..a5cdaf3e35b70 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -170,7 +170,7 @@ public function testExecuteException() $quoteMock->expects(self::once()) ->method('getItemsCount') - ->willReturn(1); + ->willReturn(0); $this->requestMock->expects(self::once()) ->method('getPostValue') @@ -188,7 +188,54 @@ public function testExecuteException() ->method('addExceptionMessage') ->with( self::isInstanceOf('\InvalidArgumentException'), - 'Data of request cannot be empty.' + 'We can\'t initialize checkout.' + ); + + $this->resultFactoryMock->expects(self::once()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($resultRedirectMock); + + $resultRedirectMock->expects(self::once()) + ->method('setPath') + ->with('checkout/cart') + ->willReturnSelf(); + + self::assertEquals($this->review->execute(), $resultRedirectMock); + } + + public function testExecuteExceptionPaymentWithoutNonce() + { + $result = '{}'; + $quoteMock = $this->getQuoteMock(); + $resultRedirectMock = $this->getResultRedirectMock(); + + $quoteMock->expects(self::once()) + ->method('getItemsCount') + ->willReturn(1); + + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) + ->disableOriginalConstructor() + ->getMock(); + + $quoteMock->expects(self::once()) + ->method('getPayment') + ->willReturn($paymentMock); + + $this->requestMock->expects(self::once()) + ->method('getPostValue') + ->with('result', '{}') + ->willReturn($result); + + $this->checkoutSessionMock->expects(self::once()) + ->method('getQuote') + ->willReturn($quoteMock); + + $this->messageManagerMock->expects(self::once()) + ->method('addExceptionMessage') + ->with( + self::isInstanceOf(\Magento\Framework\Exception\LocalizedException::class), + 'We can\'t initialize checkout.' ); $this->resultFactoryMock->expects(self::once()) diff --git a/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml b/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml index 99494ff5d889d..35cb4617ec9ed 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/paypal/button.phtml @@ -27,7 +27,7 @@ $config = [ data-locale="getLocale(); ?>" data-amount="getAmount(); ?>" id="" - class="action-braintree-paypal-logo"> + class="action-braintree-paypal-logo" disabled> Pay with PayPal diff --git a/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js b/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js index d6c0384e54c10..c2a5326aa31f6 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/paypal/button.js @@ -4,6 +4,7 @@ */ define( [ + 'rjsResolver', 'uiRegistry', 'uiComponent', 'underscore', @@ -13,6 +14,7 @@ define( 'domReady!' ], function ( + resolver, registry, Component, _, @@ -47,8 +49,10 @@ define( * @param {Object} integration */ onReady: function (integration) { - registry.set(this.integrationName, integration); - $('#' + this.id).removeAttr('disabled'); + resolver(function () { + registry.set(this.integrationName, integration); + $('#' + this.id).removeAttr('disabled'); + }, this); }, /** diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js index e1f72e3c8cb11..7d34055512cf1 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/adapter.js @@ -15,6 +15,7 @@ define([ return { apiClient: null, config: {}, + checkout: null, /** * Get Braintree api client diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js index f087da176df9b..6990c1e2e5a0b 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js @@ -184,10 +184,11 @@ define( /** * Device data initialization * - * @param {Object} braintreeInstance + * @param {Object} checkout */ - onReady: function (braintreeInstance) { - this.additionalData['device_data'] = braintreeInstance.deviceData; + onReady: function (checkout) { + braintree.checkout = checkout; + this.additionalData['device_data'] = checkout.deviceData; } }; diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js index 4155f2c25f8b0..df3d5a116699c 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js @@ -15,8 +15,6 @@ define([ ], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators) { 'use strict'; - var checkout; - return Component.extend({ defaults: { template: 'Magento_Braintree/payment/paypal', @@ -33,10 +31,10 @@ define([ /** * Triggers when widget is loaded - * @param {Object} integration + * @param {Object} checkout */ - onReady: function (integration) { - checkout = integration; + onReady: function (checkout) { + Braintree.checkout = checkout; this.enableButton(); }, @@ -144,12 +142,36 @@ define([ this.paymentMethodNonce = paymentMethodNonce; }, + /** + * Update quote billing address + * @param {Object}customer + * @param {Object}address + */ + setBillingAddress: function (customer, address) { + var billingAddress = { + street: [address.streetAddress], + city: address.locality, + regionCode: address.region, + postcode: address.postalCode, + countryId: address.countryCodeAlpha2, + firstname: customer.firstName, + lastname: customer.lastName, + telephone: customer.phone + }; + + quote.billingAddress(billingAddress); + }, + /** * Prepare data to place order * @param {Object} data */ beforePlaceOrder: function (data) { this.setPaymentMethodNonce(data.nonce); + + if (quote.billingAddress() === null && typeof data.details.billingAddress !== 'undefined') { + this.setBillingAddress(data.details, data.details.billingAddress); + } this.placeOrder(); }, @@ -157,12 +179,12 @@ define([ * Re-init PayPal Auth Flow */ reInitPayPal: function () { - if (!checkout) { - return; + if (Braintree.checkout) { + Braintree.checkout.teardown(function () { + Braintree.checkout = null; + }); } - checkout.teardown(function () { - checkout = null; - }); + this.disableButton(); this.clientConfig.paypal.amount = this.grandTotalAmount; @@ -175,7 +197,7 @@ define([ */ payWithPayPal: function () { if (additionalValidators.validate()) { - checkout.paypal.initAuthFlow(); + Braintree.checkout.paypal.initAuthFlow(); } }, @@ -200,8 +222,7 @@ define([ * @returns {Object} */ getPayPalConfig: function () { - var address = quote.shippingAddress(), - totals = quote.totals(), + var totals = quote.totals(), config = {}; config.paypal = { @@ -212,16 +233,6 @@ define([ currency: totals['base_currency_code'], locale: this.getLocale(), enableShippingAddress: true, - shippingAddressOverride: { - recipientName: address.firstname + ' ' + address.lastname, - streetAddress: address.street[0], - locality: address.city, - countryCodeAlpha2: address.countryId, - postalCode: address.postcode, - region: address.regionCode, - phone: address.telephone, - editable: this.isAllowOverrideShippingAddress() - }, /** * Triggers on any Braintree error @@ -238,6 +249,8 @@ define([ } }; + config.paypal.shippingAddressOverride = this.getShippingAddress(); + if (this.getMerchantName()) { config.paypal.displayName = this.getMerchantName(); } @@ -245,6 +258,30 @@ define([ return config; }, + /** + * Get shipping address + * @returns {Object} + */ + getShippingAddress: function () { + var address = quote.shippingAddress(); + + if (address.postcode === null) { + + return {}; + } + + return { + recipientName: address.firstname + ' ' + address.lastname, + streetAddress: address.street[0], + locality: address.city, + countryCodeAlpha2: address.countryId, + postalCode: address.postcode, + region: address.regionCode, + phone: address.telephone, + editable: this.isAllowOverrideShippingAddress() + }; + }, + /** * Get merchant name * @returns {String} @@ -279,6 +316,8 @@ define([ * Disable submit button */ disableButton: function () { + // stop any previous shown loaders + fullScreenLoader.stopLoader(); fullScreenLoader.startLoader(); $('[data-button="place"]').attr('disabled', 'disabled'); }, diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml index 9a7db79414836..3f15701216005 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml @@ -40,7 +40,6 @@ -isRedirectToCartEnabled()) : ?> - - \ No newline at end of file diff --git a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php index ca520a6a0acaf..a57a1f91dcf66 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php +++ b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php @@ -58,7 +58,7 @@ public function beforeSavePaymentInformationAndPlaceOrder( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } @@ -77,17 +77,21 @@ public function beforeSavePaymentInformation( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } /** - * @param int[] $agreements + * @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod * @throws \Magento\Framework\Exception\CouldNotSaveException * @return void */ - protected function validateAgreements($agreements) + protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod) { + $agreements = $paymentMethod->getExtensionAttributes() === null + ? [] + : $paymentMethod->getExtensionAttributes()->getAgreementIds(); + if (!$this->agreementsValidator->isValid($agreements)) { throw new \Magento\Framework\Exception\CouldNotSaveException( __('Please agree to all the terms and conditions before placing the order.') diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php index 268a746d91998..a2440cf7641a2 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php @@ -85,7 +85,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -107,7 +107,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(false); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -125,7 +125,7 @@ public function testBeforeSavePaymentInformation() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js index 0e0bd2c2234b5..d0876cc49ce0f 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js @@ -9,6 +9,9 @@ var config = { mixins: { 'Magento_Checkout/js/action/place-order': { 'Magento_CheckoutAgreements/js/model/place-order-mixin': true + }, + 'Magento_Checkout/js/action/set-payment-information': { + 'Magento_CheckoutAgreements/js/model/set-payment-information-mixin': true } } } diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js index 793978cb8e474..3d030a62eb425 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js @@ -14,6 +14,8 @@ define( var checkoutConfig = window.checkoutConfig, agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {}; + var agreementsInputPath = '.payment-method._active div.checkout-agreements input'; + return { /** * Validate checkout agreements @@ -25,6 +27,10 @@ define( return true; } + if ($(agreementsInputPath).length == 0) { + return true; + } + return $('#co-payment-form').validate({ errorClass: 'mage-error', errorElement: 'div', @@ -36,7 +42,7 @@ define( } errorPlacement.after(error); } - }).element('.payment-method._active div.checkout-agreements input'); + }).element(agreementsInputPath); } } } diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js new file mode 100644 index 0000000000000..cd2c486f0923c --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery' +], function ($) { + 'use strict'; + + var agreementsConfig = window.checkoutConfig.checkoutAgreements; + + /** Override default place order action and add agreement_ids to request */ + return function (paymentData) { + var agreementForm, + agreementData, + agreementIds; + + if (!agreementsConfig.isEnabled) { + return; + } + + agreementForm = $('.payment-method._active div[data-role=checkout-agreements] input'); + agreementData = agreementForm.serializeArray(); + agreementIds = []; + + agreementData.forEach(function (item) { + agreementIds.push(item.value); + }); + + if (paymentData['extension_attributes'] === undefined) { + paymentData['extension_attributes'] = {}; + } + + paymentData['extension_attributes']['agreement_ids'] = agreementIds; + }; +}); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js index b7008e8556223..ac459e573f9f2 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js @@ -6,35 +6,16 @@ /*global alert*/ define([ 'jquery', - 'mage/utils/wrapper' -], function ($, wrapper) { + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { 'use strict'; - var agreementsConfig = window.checkoutConfig.checkoutAgreements; - return function (placeOrderAction) { /** Override default place order action and add agreement_ids to request */ return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, messageContainer) { - var agreementForm, - agreementData, - agreementIds; - - if (!agreementsConfig.isEnabled) { - return originalAction(paymentData, messageContainer); - } - - agreementForm = $('.payment-method._active form[data-role=checkout-agreements]'); - agreementData = agreementForm.serializeArray(); - agreementIds = []; - - agreementData.forEach(function (item) { - agreementIds.push(item.value); - }); - - paymentData.extension_attributes = { - agreement_ids: agreementIds - }; + agreementsAssigner(paymentData); return originalAction(paymentData, messageContainer); }); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js new file mode 100644 index 0000000000000..159568a8b1bec --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery', + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { + 'use strict'; + + return function (placeOrderAction) { + + /** Override place-order-mixin for set-payment-information action as they differs only by method signature */ + return wrapper.wrap(placeOrderAction, function (originalAction, messageContainer, paymentData) { + agreementsAssigner(paymentData); + + return originalAction(messageContainer, paymentData); + }); + }; +}); diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php index e7a3e8ae19ba4..67ec8ec2b654d 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php @@ -5,6 +5,8 @@ */ namespace Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action; +use Magento\Store\Api\StoreResolverInterface; + class UrlBuilder { /** @@ -33,8 +35,12 @@ public function getUrl($routePath, $scope, $store) $this->frontendUrlBuilder->setScope($scope); $href = $this->frontendUrlBuilder->getUrl( $routePath, - ['_current' => false, '_query' => '___store=' . $store] + [ + '_current' => false, + '_query' => [StoreResolverInterface::PARAM_NAME => $store] + ] ); + return $href; } } diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 4cd95cb5b4ba9..2d9e162d85f1c 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -1260,7 +1260,6 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) $width = $packageParams->getWidth(); $length = $packageParams->getLength(); $weightUnits = $packageParams->getWeightUnits() == \Zend_Measure_Weight::POUND ? 'LB' : 'KG'; - $dimensionsUnits = $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM'; $unitPrice = 0; $itemsQty = 0; $itemsDesc = []; @@ -1403,12 +1402,12 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) // set dimensions if ($length || $width || $height) { - $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = []; - $dimenssions = &$requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions']; - $dimenssions['Length'] = $length; - $dimenssions['Width'] = $width; - $dimenssions['Height'] = $height; - $dimenssions['Units'] = $dimensionsUnits; + $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = [ + 'Length' => $length, + 'Width' => $width, + 'Height' => $height, + 'Units' => $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM' + ]; } return $this->_getAuthDetails() + $requestClient; diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php index 501f38834bc4d..eb45a53b98995 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php @@ -128,12 +128,13 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c $items = []; while (false !== ($csvLine = $file->readCsv())) { try { + $rowNumber++; if (empty($csvLine)) { continue; } $rowData = $this->rowParser->parse( $csvLine, - ++$rowNumber, + $rowNumber, $websiteId, $conditionShortName, $conditionFullName, @@ -151,7 +152,7 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c ) ); } - $this->uniqueHash[$hash] = $csvLine; + $this->uniqueHash[$hash] = $rowNumber; $items[] = $rowData; if (count($items) === $bunchSize) { diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php index 0bb192e3deacb..a3a2a5d1fbb8f 100644 --- a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php +++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php @@ -188,7 +188,7 @@ public function testGetDataWithDuplicatedLine() } $this->assertEquals($expectedResult, $result); $this->assertTrue($this->import->hasErrors()); - $this->assertEquals(['Duplicate Row #%1 (duplicates row #%2)'], $this->import->getErrors()); + $this->assertEquals(['Duplicate Row #3 (duplicates row #2)'], $this->import->getErrors()); } /** diff --git a/app/code/Magento/Payment/Block/Form/Cc.php b/app/code/Magento/Payment/Block/Form/Cc.php index 1871da613b254..9fcd03b446470 100644 --- a/app/code/Magento/Payment/Block/Form/Cc.php +++ b/app/code/Magento/Payment/Block/Form/Cc.php @@ -108,6 +108,7 @@ public function hasVerification() /** * Whether switch/solo card type available * + * @deprecated unused * @return bool */ public function hasSsCardType() @@ -123,6 +124,7 @@ public function hasSsCardType() /** * Solo/switch card start year * + * @deprecated unused * @return array */ public function getSsStartYears() diff --git a/app/code/Magento/Payment/Model/CcConfig.php b/app/code/Magento/Payment/Model/CcConfig.php index e80edc45da0ef..bb57756fb7e1d 100644 --- a/app/code/Magento/Payment/Model/CcConfig.php +++ b/app/code/Magento/Payment/Model/CcConfig.php @@ -62,6 +62,7 @@ public function __construct( * Solo/switch card start years * * @return array + * @deprecated unused */ public function getSsStartYears() { @@ -119,6 +120,7 @@ public function hasVerification() * Whether switch/solo card type available * * @return bool + * @deprecated unused */ public function hasSsCardType() { diff --git a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php index 768c1368f3af4..a29bff3576a16 100644 --- a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php +++ b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php @@ -51,8 +51,6 @@ public function getConfig() 'months' => [$methodCode => $this->getCcMonths()], 'years' => [$methodCode => $this->getCcYears()], 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], - 'hasSsCardType' => [$methodCode => $this->hasSsCardType($methodCode)], - 'ssStartYears' => [$methodCode => $this->getSsStartYears()], 'cvvImageUrl' => [$methodCode => $this->getCvvImageUrl()] ] ] @@ -66,6 +64,7 @@ public function getConfig() * Solo/switch card start years * * @return array + * @deprecated unused */ protected function getSsStartYears() { @@ -144,6 +143,7 @@ protected function hasVerification($methodCode) * * @param string $methodCode * @return bool + * @deprecated unused */ protected function hasSsCardType($methodCode) { diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php index aa4b8c0587a69..46663d30d8a0d 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php @@ -44,12 +44,6 @@ protected function setUp() ); } - public function testGetSsStartYears() - { - $this->assertCount(6, $this->model->getSsStartYears()); - $this->assertEquals(date("Y"), $this->model->getSsStartYears()[date("Y")]); - } - public function testGetCcAvailableTypes() { $data = [1, 2, 3]; @@ -85,11 +79,6 @@ public function testHasVerification() $this->assertEquals(true, $this->model->hasVerification()); } - public function testHasSsCardType() - { - $this->assertEquals(false, $this->model->hasSsCardType()); - } - public function testGetCvvImageUrl() { $params = ['_secure' => true]; diff --git a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml index f07aceb5ddb5f..bddf821c3b376 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml @@ -80,72 +80,4 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); - - hasSsCardType()): ?> -
-
- -
-
- - -
- -
-
-
- -
- - -
-
- -
 
- - -
- diff --git a/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml b/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml index 3a2a342c207fe..0f2782db469ac 100644 --- a/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml +++ b/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml @@ -109,64 +109,5 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); - hasSsCardType()): ?> -
-
-
- -
-
- -
- -
-
- -
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
 
-
-
- getChildHtml() ?> diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html index 2b3ea564912b9..c1cc8f009bcec 100644 --- a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html +++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html @@ -124,66 +124,4 @@ - -
-
-
- -
-
- -
- -
-
- -
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
 
-
-
- diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index b22913c7d9048..c31c708a669d1 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -437,15 +437,8 @@ protected function _placeOrder(Payment $payment, $amount) $this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()) )->setCreditCardCvv2( $payment->getCcCid() - )->setMaestroSoloIssueNumber( - $payment->getCcSsIssue() ); - if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) { - $year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2)); - $api->setMaestroSoloIssueDate($this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year)); - } - // add shipping and billing addresses if ($order->getIsVirtual()) { $api->setAddress($order->getBillingAddress())->setSuppressShipping(true); diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index e1d2c482e2c6b..92d853f661c52 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -170,6 +170,13 @@ class Settlement extends \Magento\Framework\Model\AbstractModel */ private $dateTimeColumns = ['transaction_initiation_date', 'transaction_completion_date']; + /** + * Columns with amount type + * + * @var array + */ + private $amountColumns = ['gross_transaction_amount', 'fee_amount']; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -406,6 +413,9 @@ private function getBodyItems(array $line, array $sectionColumns, array $rowMap) if (in_array($rowMap[$sectionColumns[$i]], $this->dateTimeColumns)) { $line[$i] = $this->formatDateTimeColumns($line[$i]); } + if (in_array($rowMap[$sectionColumns[$i]], $this->amountColumns)) { + $line[$i] = $this->formatAmountColumn($line[$i]); + } $bodyItem[$rowMap[$sectionColumns[$i]]] = $line[$i]; } } @@ -425,6 +435,19 @@ private function formatDateTimeColumns($lineItem) return $date->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); } + /** + * Format amount columns + * + * PayPal api returns amounts in cents, hence the values need to be divided by 100 + * + * @param string $lineItem + * @return float + */ + private function formatAmountColumn($lineItem) + { + return intval($lineItem) / 100; + } + /** * Load report by unique key (accoutn + report date) * diff --git a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php index de5b7f782b5ac..67b93d9f33d25 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement/Row.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement/Row.php @@ -122,8 +122,7 @@ public function getDebitCreditText($code) /** * Cast amounts of the specified keys * - * PayPal settlement reports contain amounts in cents, hence the values need to be divided by 100 - * Also if the "credit" value is detected, it will be casted to negative amount + * If the "credit" value is detected, it will be casted to negative amount * * @param string $key * @return float|null @@ -137,7 +136,7 @@ public function getCastedAmount($key) return null; } - $amount = $this->_data[$key] / 100; + $amount = $this->_data[$key]; if ('CR' == $this->_data[$this->castAmountRelation[$key]]) { $amount = -1 * $amount; } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php index f427798367940..2cf4bd90ee177 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/Report/Settlement/RowTest.php @@ -107,8 +107,8 @@ public function getDebitCreditTextDataProvider() public function getCastedAmountDataProvider() { return [ - ['fee_amount', ['fee_amount' => 100, 'fee_debit_or_credit' => 'CR'], -1], - ['fee_amount', ['fee_amount' => 100, 'fee_debit_or_credit' => 'DB'], 1] + ['fee_amount', ['fee_amount' => 1, 'fee_debit_or_credit' => 'CR'], -1], + ['fee_amount', ['fee_amount' => 1, 'fee_debit_or_credit' => 'DB'], 1] ]; } } diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml index 733fbcdb36521..4ee83da9c2ab8 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml @@ -122,6 +122,7 @@ + diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index 7e408a0ec5cf6..4b98fe9309b76 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -110,8 +110,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card expiration month. */ const CC_EXP_MONTH = 'cc_exp_month'; - /* + + /** * Credit card SS start year. + * + * @deprecated unused constant */ const CC_SS_START_YEAR = 'cc_ss_start_year'; /* @@ -154,8 +157,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card debug response serialized. */ const CC_DEBUG_RESPONSE_SERIALIZED = 'cc_debug_response_serialized'; - /* + + /** * Credit card SS start month. + * + * @deprecated unused constant */ const CC_SS_START_MONTH = 'cc_ss_start_month'; /* @@ -206,8 +212,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card debug response body. */ const CC_DEBUG_RESPONSE_BODY = 'cc_debug_response_body'; - /* + + /** * Credit card SS issue. + * + * @deprecated unused constant */ const CC_SS_ISSUE = 'cc_ss_issue'; /* @@ -463,6 +472,7 @@ public function getCcSecureVerify(); * Gets the credit card SS issue for the order payment. * * @return string|null Credit card SS issue. + * @deprecated unused */ public function getCcSsIssue(); @@ -470,6 +480,7 @@ public function getCcSsIssue(); * Gets the credit card SS start month for the order payment. * * @return string|null Credit card SS start month. + * @deprecated unused */ public function getCcSsStartMonth(); @@ -477,6 +488,7 @@ public function getCcSsStartMonth(); * Gets the credit card SS start year for the order payment. * * @return string|null Credit card SS start year. + * @deprecated unused */ public function getCcSsStartYear(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php index 99310038a02f4..9a910e48ec0f2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php @@ -101,6 +101,7 @@ public function getQuote() * Whether switch/solo card type available * * @return true + * @deprecated unused */ public function hasSsCardType() { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php index 25fb917184b32..32bb784bc7a3f 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php @@ -7,7 +7,10 @@ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; use Magento\Backend\App\Action\Context; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Registry; +use Magento\Sales\Api\InvoiceRepositoryInterface; +use Magento\Sales\Model\Order\InvoiceRepository; abstract class View extends \Magento\Backend\App\Action { @@ -28,6 +31,11 @@ abstract class View extends \Magento\Backend\App\Action */ protected $resultForwardFactory; + /** + * @var InvoiceRepositoryInterface + */ + protected $invoiceRepository; + /** * @param Context $context * @param Registry $registry @@ -66,16 +74,30 @@ public function execute() */ protected function getInvoice() { - $invoiceId = $this->getRequest()->getParam('invoice_id'); - if (!$invoiceId) { + try { + $invoice = $this->getInvoiceRepository() + ->get($this->getRequest()->getParam('invoice_id')); + $this->registry->register('current_invoice', $invoice); + } catch (\Exception $e) { + $this->messageManager->addError(__('Invoice capturing error')); return false; } - /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); - if (!$invoice) { - return false; - } - $this->registry->register('current_invoice', $invoice); + return $invoice; } + + /** + * @return InvoiceRepository + * + * @deprecated + */ + private function getInvoiceRepository() + { + if ($this->invoiceRepository === null) { + $this->invoiceRepository = ObjectManager::getInstance() + ->get(InvoiceRepositoryInterface::class); + } + + return $this->invoiceRepository; + } } diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index 3f251c79eebfa..8c6f2e55f55ac 100644 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -47,7 +47,8 @@ class Config */ protected $maskStatusesMapping = [ \Magento\Framework\App\Area::AREA_FRONTEND => [ - \Magento\Sales\Model\Order::STATUS_FRAUD => \Magento\Sales\Model\Order::STATE_PROCESSING + \Magento\Sales\Model\Order::STATUS_FRAUD => \Magento\Sales\Model\Order::STATE_PROCESSING, + \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW => \Magento\Sales\Model\Order::STATE_PROCESSING ] ]; diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 76f612851359d..898a205481d1a 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1703,6 +1703,7 @@ public function getCcSecureVerify() * Returns cc_ss_issue * * @return string + * @deprecated unused */ public function getCcSsIssue() { @@ -1713,6 +1714,7 @@ public function getCcSsIssue() * Returns cc_ss_start_month * * @return string + * @deprecated unused */ public function getCcSsStartMonth() { @@ -1723,6 +1725,7 @@ public function getCcSsStartMonth() * Returns cc_ss_start_year * * @return string + * @deprecated unused */ public function getCcSsStartYear() { @@ -2087,6 +2090,7 @@ public function setCcExpMonth($ccExpMonth) /** * {@inheritdoc} + * @deprecated unused */ public function setCcSsStartYear($ccSsStartYear) { @@ -2175,6 +2179,7 @@ public function setCcDebugResponseSerialized($ccDebugResponseSerialized) /** * {@inheritdoc} + * @deprecated unused */ public function setCcSsStartMonth($ccSsStartMonth) { @@ -2279,6 +2284,7 @@ public function setCcDebugResponseBody($ccDebugResponseBody) /** * {@inheritdoc} + * @deprecated unused */ public function setCcSsIssue($ccSsIssue) { diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php index 93d776a35d1f1..33d89a4173706 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -7,10 +7,12 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class AddCommentTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddCommentTest extends \PHPUnit_Framework_TestCase { @@ -34,11 +36,6 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected $viewMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $objectManagerMock; - /** * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ @@ -79,6 +76,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected $resultJsonMock; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * SetUp method * @@ -104,10 +106,6 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') ->disableOriginalConstructor() ->getMock(); @@ -133,9 +131,6 @@ protected function setUp() $contextMock->expects($this->any()) ->method('getView') ->will($this->returnValue($this->viewMock)); - $contextMock->expects($this->any()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); $this->viewMock->expects($this->any()) ->method('getPage') ->willReturn($this->resultPageMock); @@ -150,26 +145,26 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->commentSenderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment', [ @@ -180,6 +175,12 @@ protected function setUp() 'resultJsonFactory' => $this->resultJsonFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -218,16 +219,9 @@ public function testExecute() $invoiceMock->expects($this->once()) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); $commentsBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View\Comments') ->disableOriginalConstructor() diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php index 6331e60c69d1c..56c3cf42146a8 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class CancelTest @@ -64,6 +65,11 @@ class CancelTest extends \PHPUnit_Framework_TestCase */ protected $controller; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void */ @@ -141,6 +147,10 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel', [ @@ -148,6 +158,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -196,18 +212,11 @@ public function testExecute() ->method('addSuccess') ->with('You canceled the invoice.'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(1)) + $this->objectManagerMock->expects($this->once()) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -241,18 +250,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->setMethods([]) @@ -297,18 +298,10 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) @@ -353,18 +346,10 @@ public function testExecuteException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php index e74264e8fb681..88d39a0a885f0 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class CaptureTest @@ -69,6 +70,11 @@ class CaptureTest extends \PHPUnit_Framework_TestCase */ protected $invoiceManagement; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void */ @@ -149,11 +155,13 @@ protected function setUp() $this->invoiceManagement = $this->getMockBuilder('Magento\Sales\Api\InvoiceManagementInterface') ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock->expects($this->any()) ->method('get') ->with('Magento\Sales\Api\InvoiceManagementInterface') ->willReturn($this->invoiceManagement); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture', @@ -162,6 +170,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock, ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -219,18 +233,11 @@ public function testExecute() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(2)) + $this->objectManagerMock->expects($this->at(1)) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -259,18 +266,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->getMock(); @@ -318,18 +317,10 @@ public function testExecuteModelException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->getMock(); @@ -377,18 +368,10 @@ public function testExecuteException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php index 8e4ade54c2911..1a6ca7c8b3e22 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class ViewTest @@ -49,11 +50,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected $invoiceLoaderMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $objectManagerMock; - /** * @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ @@ -84,6 +80,11 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected $resultForwardFactoryMock; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + protected function setUp() { $objectManager = new ObjectManager($this); @@ -112,7 +113,6 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getCommentText', 'setIsUrlNotice']) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') ->disableOriginalConstructor() ->getMock(); @@ -145,9 +145,6 @@ protected function setUp() $contextMock->expects($this->any()) ->method('getSession') ->will($this->returnValue($this->sessionMock)); - $contextMock->expects($this->any()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); $this->viewMock->expects($this->any()) ->method('getPage') ->willReturn($this->resultPageMock); @@ -162,11 +159,13 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\View', @@ -176,6 +175,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } public function testExecute() @@ -226,18 +231,10 @@ public function testExecute() ->setMethods([]) ->getMock(); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); $this->resultPageFactoryMock->expects($this->once()) @@ -256,18 +253,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php index 4cd66680b139d..305c55ba63dca 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class VoidTest @@ -74,8 +75,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase */ protected $invoiceManagement; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { @@ -167,6 +174,10 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Void', [ @@ -174,6 +185,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -225,18 +242,11 @@ public function testExecute() $transactionMock->expects($this->at(2)) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(2)) + $this->objectManagerMock->expects($this->at(1)) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -270,18 +280,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->messageManagerMock->expects($this->never()) ->method('addError'); $this->messageManagerMock->expects($this->never()) @@ -329,18 +331,10 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->messageManagerMock->expects($this->once()) ->method('addError'); diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml index 97650870dc451..a545240534258 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml @@ -144,7 +144,7 @@ - + textRange diff --git a/app/code/Magento/Search/view/frontend/web/form-mini.js b/app/code/Magento/Search/view/frontend/web/form-mini.js index cceda751f6317..7c9bc4255fb21 100644 --- a/app/code/Magento/Search/view/frontend/web/form-mini.js +++ b/app/code/Magento/Search/view/frontend/web/form-mini.js @@ -71,14 +71,18 @@ define([ }.bind(this) }); + this.searchLabel.on('click', function (e) { + // allow input to lose its' focus when clicking on label + if (this.isExpandable && this.isActive()) { + e.preventDefault(); + } + }.bind(this)); + this.element.on('blur', $.proxy(function () { setTimeout($.proxy(function () { if (this.autoComplete.is(':hidden')) { - this.searchLabel.removeClass('active'); - if (this.isExpandable === true) { - this.element.attr('aria-expanded', 'false'); - } + this.setActiveState(false); } this.autoComplete.hide(); this._updateAriaHasPopup(false); @@ -87,12 +91,7 @@ define([ this.element.trigger('blur'); - this.element.on('focus', $.proxy(function () { - this.searchLabel.addClass('active'); - if (this.isExpandable === true) { - this.element.attr('aria-expanded', 'true'); - } - }, this)); + this.element.on('focus', this.setActiveState.bind(this, true)); this.element.on('keydown', this._onKeyDown); this.element.on('input propertychange', this._onPropertyChange); @@ -101,6 +100,29 @@ define([ this._updateAriaHasPopup(false); }, this)); }, + + /** + * Checks if search field is active. + * + * @returns {Boolean} + */ + isActive: function () { + return this.searchLabel.hasClass('active'); + }, + + /** + * Sets state of the search field to provided value. + * + * @param {Boolean} isActive + */ + setActiveState: function (isActive) { + this.searchLabel.toggleClass('active', isActive); + + if (this.isExpandable) { + this.element.attr('aria-expanded', isActive); + } + }, + /** * @private * @return {Element} The first element in the suggestion list. diff --git a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js index 3a5959e1b0358..2ad2ff596a707 100644 --- a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js +++ b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js @@ -230,7 +230,7 @@ Packaging.prototype = { validate: function() { var dimensionElements = $("packaging_window").select( - 'input[name=container_length],input[name=container_width],input[name=container_height]' + 'input[name=container_length],input[name=container_width],input[name=container_height],input[name=container_girth]:not("._disabled")' ); var callback = null; if ( dimensionElements.any(function(element) { return !!element.value; })) { @@ -543,8 +543,7 @@ Packaging.prototype = { return; } - var girthEnabled = (packageSize[0].value == 'LARGE' && (packageContainer[0].value == 'NONRECTANGULAR' - || packageContainer[0].value == 'VARIABLE' )); + var girthEnabled = packageContainer[0].value == 'NONRECTANGULAR' || packageContainer[0].value == 'VARIABLE'; if (!girthEnabled) { packageGirth[0].value=''; diff --git a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php index 3118cd9b7669e..b0a91da7a07bc 100644 --- a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php +++ b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php @@ -69,7 +69,7 @@ public function aroundCheckSizeAndGirthParameter(\Magento\Framework\DataObject $ $girthEnabled = false; $sizeEnabled = false; if ($carrier && isset($size[0]['value'])) { - if ($size[0]['value'] == Carrier::SIZE_LARGE && in_array( + if (in_array( key($subject->getContainers()), [Carrier::CONTAINER_NONRECTANGULAR, Carrier::CONTAINER_VARIABLE] ) diff --git a/app/code/Magento/Vault/view/frontend/web/template/payment/form.html b/app/code/Magento/Vault/view/frontend/web/template/payment/form.html index b444ebbebdaf6..85ff6148bb6f0 100644 --- a/app/code/Magento/Vault/view/frontend/web/template/payment/form.html +++ b/app/code/Magento/Vault/view/frontend/web/template/payment/form.html @@ -32,7 +32,11 @@
- +
+ + + +