Skip to content

Commit

Permalink
MAGETWO-87154: [EngCom Team] Batch 14. Forwardports to 2.3-develop #1299
Browse files Browse the repository at this point in the history


 - Merge Pull Request magento-engcom/magento2ce#1299 from magento-engcom-team/magento2:batch-14-forwardport-2.3-develop
 - Merged commits:
   1. 99e3a76
   2. 4cfc07e
   3. ea616e0
   4. be55217
   5. 41c52fb
   6. 7f42a67
   7. 1090c8b
   8. c80b5ca
   9. 8077af7
   10. 38e34a8
   11. c13ad85
   12. 9e7bf93
   13. 10a6288
   14. abf31d2
   15. 898a470
   16. c99c3a7
   17. 4537e78
   18. 0bad56f
   19. fd2418e
   20. 946e9e1
  • Loading branch information
Oleksii Korshenko committed Jan 24, 2018
2 parents c7207f6 + 946e9e1 commit d236abd
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 61 deletions.
4 changes: 2 additions & 2 deletions app/bootstrap.php
Expand Up @@ -14,12 +14,12 @@
if (!defined('PHP_VERSION_ID') || !(PHP_VERSION_ID === 70002 || PHP_VERSION_ID === 70004 || PHP_VERSION_ID >= 70006)) {
if (PHP_SAPI == 'cli') {
echo 'Magento supports 7.0.2, 7.0.4, and 7.0.6 or later. ' .
'Please read http://devdocs.magento.com/guides/v1.0/install-gde/system-requirements.html';
'Please read http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html';
} else {
echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
<p>Magento supports PHP 7.0.2, 7.0.4, and 7.0.6 or later. Please read
<a target="_blank" href="http://devdocs.magento.com/guides/v1.0/install-gde/system-requirements.html">
<a target="_blank" href="http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html">
Magento System Requirements</a>.
</div>
HTML;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/etc/adminhtml/system.xml
Expand Up @@ -231,7 +231,7 @@
<label>European Union Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
<field id="destinations" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="destinations" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Top destinations</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
Expand Down
Expand Up @@ -79,6 +79,7 @@ define(
*/
onError: function (response) {
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
this.isPlaceOrderActionAllowed(true);
throw response.message;
},

Expand Down
Expand Up @@ -57,7 +57,7 @@ $stores = $block->getStoresSortedBySortOrder();
<input type="hidden" id="option-count-check" value="" />
</div>
<script id="row-template" type="text/x-magento-template">
<tr>
<tr <% if (data.rowClasses) { %>class="<%- data.rowClasses %>"<% } %>>
<td class="col-draggable">
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()): ?>
<div data-role="draggable-handle" class="draggable-handle"
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Catalog/view/adminhtml/web/js/options.js
Expand Up @@ -24,6 +24,7 @@ define([
totalItems: 0,
rendered: 0,
template: mageTemplate('#row-template'),
newOptionClass: 'new-option',
isReadOnly: config.isReadOnly,
add: function (data, render) {
var isNewOption = false,
Expand All @@ -32,7 +33,8 @@ define([
if (typeof data.id == 'undefined') {
data = {
'id': 'option_' + this.itemCount,
'sort_order': this.itemCount + 1
'sort_order': this.itemCount + 1,
'rowClasses': this.newOptionClass
};
isNewOption = true;
}
Expand Down Expand Up @@ -84,6 +86,10 @@ define([
this.totalItems--;
this.updateItemsCountField();
}

if (element.hasClassName(this.newOptionClass)) {
element.remove();
}
},
updateItemsCountField: function () {
$('option-count-check').value = this.totalItems > 0 ? '1' : '';
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Directory/etc/adminhtml/system.xml
Expand Up @@ -109,6 +109,7 @@
<field id="state_required" translate="label" type="multiselect" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<label>State is Required for</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="display_all" translate="label" type="select" sortOrder="8" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Allow to Choose State if It is Optional for Country</label>
Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/Paypal/Model/Express.php
Expand Up @@ -669,14 +669,19 @@ public function getApi()
public function assignData(\Magento\Framework\DataObject $data)
{
parent::assignData($data);

$additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);

if (!is_array($additionalData)) {
return $this;
}

foreach ($additionalData as $key => $value) {
// Skip extension attributes
if ($key === \Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY) {
continue;
}

$this->getInfoInstance()->setAdditionalInformation($key, $value);
}
return $this;
Expand Down
11 changes: 10 additions & 1 deletion app/code/Magento/Paypal/Test/Unit/Model/ExpressTest.php
Expand Up @@ -161,12 +161,21 @@ public function testAssignData()
{
$transportValue = 'something';

$extensionAttribute = $this->getMockForAbstractClass(
\Magento\Quote\Api\Data\PaymentExtensionInterface::class,
[],
'',
false,
false
);

$data = new DataObject(
[
PaymentInterface::KEY_ADDITIONAL_DATA => [
Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => $transportValue,
Express\Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID => $transportValue,
Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN => $transportValue
Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN => $transportValue,
\Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $extensionAttribute
]
]
);
Expand Down
Expand Up @@ -4,48 +4,12 @@
*/

define([
'jquery',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/error-processor',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
], function ($, quote, urlBuilder, storage, errorProcessor, customer, fullScreenLoader) {
'Magento_Checkout/js/action/set-payment-information'
], function (quote, setPaymentInformation) {
'use strict';

return function (messageContainer) {
var serviceUrl,
payload,
paymentData = quote.paymentMethod();

/**
* Checkout for guest and registered customer.
*/
if (!customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/set-payment-information', {
cartId: quote.getQuoteId()
});
payload = {
cartId: quote.getQuoteId(),
email: quote.guestEmail,
paymentMethod: paymentData
};
} else {
serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {});
payload = {
cartId: quote.getQuoteId(),
paymentMethod: paymentData
};
}
fullScreenLoader.startLoader();

return storage.post(
serviceUrl, JSON.stringify(payload)
).fail(function (response) {
errorProcessor.process(response, messageContainer);
}).always(function () {
fullScreenLoader.stopLoader();
});
return setPaymentInformation(messageContainer, quote.paymentMethod());
};
});
8 changes: 7 additions & 1 deletion app/code/Magento/Theme/Block/Html/Topmenu.php
Expand Up @@ -235,7 +235,13 @@ protected function _getHtml(

if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
$currentClass = $child->getClass();

if (empty($currentClass)) {
$child->setClass($outermostClass);
} else {
$child->setClass($currentClass . ' ' . $outermostClass);
}
}

if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
Expand Down
Expand Up @@ -42,6 +42,14 @@
max-height: 250px;
overflow-y: auto;
padding-top: .25em;
&::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
&::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0, 0, 0, .5);
}

li {
border: 0;
Expand Down
2 changes: 2 additions & 0 deletions dev/tests/integration/etc/di/preferences/ce.php
Expand Up @@ -16,6 +16,8 @@
\Magento\Framework\App\Response\Http::class => \Magento\TestFramework\Response::class,
\Magento\Framework\Interception\PluginListInterface::class =>
\Magento\TestFramework\Interception\PluginList::class,
\Magento\Framework\Interception\ObjectManager\ConfigInterface::class =>
\Magento\TestFramework\ObjectManager\Config::class,
\Magento\Framework\Interception\ObjectManager\Config\Developer::class =>
\Magento\TestFramework\ObjectManager\Config::class,
\Magento\Framework\View\LayoutInterface::class => \Magento\TestFramework\View\Layout::class,
Expand Down
Expand Up @@ -27,7 +27,7 @@ define([
),
'Magento_Braintree/js/view/payment/adapter': jasmine.createSpyObj(
'adapter',
['setup', 'setConfig']
['setup', 'setConfig', 'showError']
)
},
braintreeCcForm;
Expand All @@ -43,14 +43,17 @@ define([
};
injector.mock(mocks);
injector.require(['Magento_Braintree/js/view/payment/method-renderer/cc-form'], function (Constr) {
braintreeCcForm = new Constr({
provider: 'provName',
name: 'test',
index: 'test'
});

done();
braintreeCcForm = new Constr({
provider: 'provName',
name: 'test',
index: 'test',
item: {
title: 'Braintree'
}
});

done();
});
});

it('Check if payment code and message container are restored after onActiveChange call.', function () {
Expand All @@ -65,5 +68,21 @@ define([
expect(braintreeCcForm.getCode()).toEqual(expectedCode);
expect(braintreeCcForm.messageContainer).toEqual(expectedMessageContainer);
});

it('Check if form validation fails when "Place Order" button should be active.', function () {
var errorMessage = 'Something went wrong.',

/**
* Anonymous wrapper
*/
func = function () {
braintreeCcForm.clientConfig.onError({
'message': errorMessage
});
};

expect(func).toThrow(errorMessage);
expect(braintreeCcForm.isPlaceOrderActionAllowed()).toBeTruthy();
});
});
});
@@ -0,0 +1,55 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'squire'
], function (Squire) {
'use strict';

var injector = new Squire(),
mocks = {
'Magento_Checkout/js/action/place-order': jasmine.createSpy('placeOrderAction'),
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner')
},
defaultContext = require.s.contexts._,
mixin,
placeOrderAction;

beforeEach(function (done) {
window.checkoutConfig = {
checkoutAgreements: {
isEnabled: true
}
};
injector.mock(mocks);
injector.require([
'Magento_CheckoutAgreements/js/model/place-order-mixin',
'Magento_Checkout/js/action/place-order'
], function (Mixin, placeOrder) {
mixin = Mixin;
placeOrderAction = placeOrder;
done();
});
});

describe('Magento_CheckoutAgreements/js/model/place-order-mixin', function () {
it('mixin is applied to Magento_Checkout/js/action/place-order', function () {
var placeOrderMixins = defaultContext.config.config.mixins['Magento_Checkout/js/action/place-order'];

expect(placeOrderMixins['Magento_CheckoutAgreements/js/model/place-order-mixin']).toBe(true);
});

it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () {
var messageContainer = jasmine.createSpy('messageContainer'),
paymentData = {};

mixin(placeOrderAction)(paymentData, messageContainer);
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner'])
.toHaveBeenCalledWith(paymentData);
expect(mocks['Magento_Checkout/js/action/place-order'])
.toHaveBeenCalledWith(paymentData, messageContainer);
});
});
});
@@ -0,0 +1,56 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'squire'
], function (Squire) {
'use strict';

var injector = new Squire(),
mocks = {
'Magento_Checkout/js/action/set-payment-information': jasmine.createSpy('placeOrderAction'),
'Magento_CheckoutAgreements/js/model/agreements-assigner': jasmine.createSpy('agreementsAssigner')
},
defaultContext = require.s.contexts._,
mixin,
placeOrderAction;

beforeEach(function (done) {
window.checkoutConfig = {
checkoutAgreements: {
isEnabled: true
}
};
injector.mock(mocks);
injector.require([
'Magento_CheckoutAgreements/js/model/set-payment-information-mixin',
'Magento_Checkout/js/action/set-payment-information'
], function (Mixin, setPaymentInformation) {
mixin = Mixin;
placeOrderAction = setPaymentInformation;
done();
});
});

describe('Magento_CheckoutAgreements/js/model/set-payment-information-mixin', function () {
it('mixin is applied to Magento_Checkout/js/action/set-payment-information', function () {
var placeOrderMixins = defaultContext
.config.config.mixins['Magento_Checkout/js/action/set-payment-information'];

expect(placeOrderMixins['Magento_CheckoutAgreements/js/model/set-payment-information-mixin']).toBe(true);
});

it('Magento_CheckoutAgreements/js/model/agreements-assigner is called', function () {
var messageContainer = jasmine.createSpy('messageContainer'),
paymentData = {};

mixin(placeOrderAction)(messageContainer, paymentData);
expect(mocks['Magento_CheckoutAgreements/js/model/agreements-assigner'])
.toHaveBeenCalledWith(paymentData);
expect(mocks['Magento_Checkout/js/action/set-payment-information'])
.toHaveBeenCalledWith(messageContainer, paymentData);
});
});
});

0 comments on commit d236abd

Please sign in to comment.