Skip to content

Commit 418f63e

Browse files
author
vpaladiychuk
committed
Merge remote-tracking branch 'mainline/merchant_beta' into MAGETWO-43795-MB
2 parents a268ecf + c8ba429 commit 418f63e

File tree

23 files changed

+223
-75
lines changed

23 files changed

+223
-75
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ define(
8080
var countryId = $('select[name="shippingAddress[country_id]"]').val();
8181
var validationResult = postcodeValidator.validate(postcodeElement.value(), countryId);
8282

83-
postcodeElement.error(null);
83+
postcodeElement.warn(null);
8484
if (!validationResult) {
85-
var errorMessage = $t('Invalid Zip/Postal code for current country!');
85+
var warnMessage = $t('Provided Zip/Postal Code seems to be invalid.');
8686
if (postcodeValidator.validatedPostCodeExample.length) {
87-
errorMessage += $t(' Example: ') + postcodeValidator.validatedPostCodeExample.join('; ');
87+
warnMessage += $t(' Example: ') + postcodeValidator.validatedPostCodeExample.join('; ') + '. ';
8888
}
89-
postcodeElement.error(errorMessage);
89+
warnMessage += $t('If you believe it is the right one you can ignore this notice.');
90+
postcodeElement.warn(warnMessage);
9091
}
9192
return validationResult;
9293
},

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function setStreet($street)
253253
}
254254

255255
/**
256-
* Enforce format of the street field
256+
* Enforce format of the street field or other multiline custom attributes
257257
*
258258
* @param array|string $key
259259
* @param null $value
@@ -263,12 +263,22 @@ public function setData($key, $value = null)
263263
{
264264
if (is_array($key)) {
265265
$key = $this->_implodeArrayField($key);
266-
} elseif (is_array($value)) {
266+
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
267267
$value = $this->_implodeArrayValues($value);
268268
}
269269
return parent::setData($key, $value);
270270
}
271271

272+
/**
273+
* Check that address can have multiline attribute by this code (as street or some custom attribute)
274+
* @param string $code
275+
* @return bool
276+
*/
277+
protected function isAddressMultilineAttribute($code)
278+
{
279+
return $code == 'street' || in_array($code, $this->getCustomAttributesCodes());
280+
}
281+
272282
/**
273283
* Implode value of the array field, if it is present among other fields
274284
*
@@ -278,7 +288,7 @@ public function setData($key, $value = null)
278288
protected function _implodeArrayField(array $data)
279289
{
280290
foreach ($data as $key => $value) {
281-
if (is_array($value)) {
291+
if (is_array($value) && $this->isAddressMultilineAttribute($key)) {
282292
$data[$key] = $this->_implodeArrayValues($data[$key]);
283293
}
284294
}

app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public function testSetData()
242242
*/
243243
public function testSetDataWithMultidimensionalArray()
244244
{
245+
$this->markTestSkipped('Need to revert changes from MAGETWO-39106 and then modify this test.');
245246
$expected = [
246247
'key' => 'value',
247248
'array' => 'value1',
@@ -266,10 +267,10 @@ public function testSetDataWithMultidimensionalArray()
266267
public function testSetDataWithValue()
267268
{
268269
$value = [
269-
'key' => 'value',
270+
'street' => 'value',
270271
];
271272

272-
$this->model->setData('key', $value);
273+
$this->model->setData('street', $value);
273274
$this->assertEquals($value, $this->model->getData());
274275
}
275276

app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testCollectItemNoDiscount()
113113
->getMock();
114114
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
115115
->disableOriginalConstructor()
116-
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
116+
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
117117
->getMock();
118118
$addressMock->expects($this->any())
119119
->method('getQuote')
@@ -124,6 +124,9 @@ public function testCollectItemNoDiscount()
124124
$addressMock->expects($this->any())
125125
->method('getShippingAmount')
126126
->willReturn(true);
127+
$addressMock->expects($this->any())
128+
->method('getCustomAttributesCodes')
129+
->willReturn([]);
127130

128131
$this->assertInstanceOf(
129132
'Magento\SalesRule\Model\Quote\Discount',
@@ -165,7 +168,7 @@ public function testCollectItemHasParent()
165168
->getMock();
166169
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
167170
->disableOriginalConstructor()
168-
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
171+
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
169172
->getMock();
170173
$addressMock->expects($this->any())
171174
->method('getQuote')
@@ -176,6 +179,9 @@ public function testCollectItemHasParent()
176179
$addressMock->expects($this->any())
177180
->method('getShippingAmount')
178181
->willReturn(true);
182+
$addressMock->expects($this->any())
183+
->method('getCustomAttributesCodes')
184+
->willReturn([]);
179185

180186
$this->assertInstanceOf(
181187
'Magento\SalesRule\Model\Quote\Discount',
@@ -249,7 +255,7 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte
249255
->getMock();
250256
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
251257
->disableOriginalConstructor()
252-
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
258+
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
253259
->getMock();
254260
$addressMock->expects($this->any())
255261
->method('getQuote')
@@ -260,6 +266,9 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte
260266
$addressMock->expects($this->any())
261267
->method('getShippingAmount')
262268
->willReturn(true);
269+
$addressMock->expects($this->any())
270+
->method('getCustomAttributesCodes')
271+
->willReturn([]);
263272

264273
$this->assertInstanceOf(
265274
'Magento\SalesRule\Model\Quote\Discount',
@@ -368,7 +377,7 @@ public function testCollectItemHasNoChildren()
368377
->getMock();
369378
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
370379
->disableOriginalConstructor()
371-
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
380+
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
372381
->getMock();
373382
$addressMock->expects($this->any())
374383
->method('getQuote')
@@ -379,6 +388,9 @@ public function testCollectItemHasNoChildren()
379388
$addressMock->expects($this->any())
380389
->method('getShippingAmount')
381390
->willReturn(true);
391+
$addressMock->expects($this->any())
392+
->method('getCustomAttributesCodes')
393+
->willReturn([]);
382394

383395
$this->assertInstanceOf(
384396
'Magento\SalesRule\Model\Quote\Discount',

app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,17 @@ protected function getAddressMock($shippingAmount = null)
525525

526526
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
527527
->disableOriginalConstructor()
528-
->setMethods(['getShippingAmountForDiscount', 'getQuote'])
528+
->setMethods(['getShippingAmountForDiscount', 'getQuote', 'getCustomAttributesCodes'])
529529
->getMock();
530530
$addressMock->expects($this->any())
531531
->method('getShippingAmountForDiscount')
532532
->willReturn($shippingAmount);
533533
$addressMock->expects($this->any())
534534
->method('getQuote')
535535
->willReturn($quoteMock);
536+
$addressMock->expects($this->any())
537+
->method('getCustomAttributesCodes')
538+
->willReturn([]);
536539
return $addressMock;
537540
}
538541

app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,21 @@ public function testMapQuoteExtraTaxables($itemData, $addressData)
516516

517517
$address = $this->getMockBuilder('\Magento\Quote\Model\Quote\Address')
518518
->disableOriginalConstructor()
519-
->setMethods(['getAssociatedTaxables', 'getQuote', 'getBillingAddress', 'getRegionId', '__wakeup'])
519+
->setMethods(
520+
[
521+
'getAssociatedTaxables',
522+
'getQuote',
523+
'getBillingAddress',
524+
'getRegionId',
525+
'__wakeup',
526+
'getCustomAttributesCodes'
527+
]
528+
)
520529
->getMock();
530+
$address
531+
->expects($this->any())
532+
->method('getCustomAttributesCodes')
533+
->willReturn([]);
521534
$quote
522535
->expects($this->any())
523536
->method('getBillingAddress')
@@ -596,7 +609,7 @@ public function testFetch($appliedTaxesData, $addressData)
596609
'\Magento\Quote\Model\Quote\Address',
597610
[
598611
'getAppliedTaxes', 'getQuote', 'getAllItems', 'getGrandTotal', '__wakeup',
599-
'addTotal', 'getTaxAmount'
612+
'addTotal', 'getTaxAmount', 'getCustomAttributesCodes'
600613
],
601614
[],
602615
'',
@@ -626,6 +639,10 @@ public function testFetch($appliedTaxesData, $addressData)
626639
->expects($this->any())
627640
->method('getTaxAmount')
628641
->will($this->returnValue(8));
642+
$address
643+
->expects($this->any())
644+
->method('getCustomAttributesCodes')
645+
->willReturn([]);
629646

630647
$addressData["cached_items_all"] = $items;
631648
foreach ($addressData as $key => $value) {

app/code/Magento/Ui/view/base/web/js/form/element/abstract.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define([
2424
description: '',
2525
label: '',
2626
error: '',
27+
warn: '',
2728
notice: '',
2829
customScope: '',
2930
additionalClasses: {},
@@ -67,7 +68,7 @@ define([
6768

6869
this._super();
6970

70-
this.observe('error disabled focused preview visible value')
71+
this.observe('error disabled focused preview visible value warn')
7172
.observe({
7273
'required': !!rules['required-entry']
7374
});
@@ -115,6 +116,7 @@ define([
115116
_.extend(this.additionalClasses, {
116117
required: this.required,
117118
_error: this.error,
119+
_warn: this.warn,
118120
_disabled: this.disabled
119121
});
120122

app/code/Magento/Ui/view/frontend/web/templates/form/field.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<!-- ko if: element.error() -->
4343
<div class="mage-error" data-bind="attr: { for: element.uid }, text: element.error" generated="true"></div>
4444
<!-- /ko -->
45+
46+
<!-- ko if: element.warn() -->
47+
<div class="message warning" generated="true"><span data-bind="text: element.warn"></span></div>
48+
<!-- /ko -->
4549
</div>
4650
</div>
4751
<!-- /ko -->

app/code/Magento/Weee/Test/Unit/Model/Total/Quote/WeeeTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ protected function setupAddressMock($itemMock)
121121
'__wakeup',
122122
'getAllItems',
123123
'getQuote',
124+
'getCustomAttributesCodes'
124125
],
125126
[],
126127
'',
@@ -136,6 +137,7 @@ protected function setupAddressMock($itemMock)
136137

137138
$addressMock->expects($this->any())->method('getAllItems')->will($this->returnValue([$itemMock]));
138139
$addressMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
140+
$addressMock->expects($this->any())->method('getCustomAttributesCodes')->willReturn([]);
139141

140142
return $addressMock;
141143
}

app/design/frontend/Magento/blank/web/css/source/_forms.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ fieldset.field {
7070
white-space: nowrap;
7171
}
7272
}
73+
.message {
74+
&.warning {
75+
margin-top: @indent__s;
76+
}
77+
}
7378
}
7479

7580
div.mage-error[generated] {

app/design/frontend/Magento/luma/web/css/source/_forms.less

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ fieldset.field {
5959
border: 0;
6060
padding: 0;
6161
}
62-
.field.date {
63-
.time-picker {
64-
white-space: nowrap;
65-
margin-top: @indent__s;
66-
display: inline-block;
62+
.field {
63+
&.date {
64+
.time-picker {
65+
white-space: nowrap;
66+
margin-top: @indent__s;
67+
display: inline-block;
68+
}
69+
}
70+
.message {
71+
&.warning {
72+
margin-top: @indent__s;
73+
}
6774
}
6875
}
6976

lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/EntityChildTestAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function testGenerate()
126126
protected function mockDefinedClassesCall()
127127
{
128128
$this->definedClassesMock->expects($this->at(0))
129-
->method('classLoadable')
129+
->method('isClassLoadable')
130130
->with($this->getSourceClassName())
131131
->willReturn(true);
132132
}

lib/internal/Magento/Framework/Autoload/AutoloaderInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ public function setPsr4($nsPrefix, $paths);
5555
* @return bool
5656
*/
5757
public function loadClass($className);
58+
59+
/**
60+
* Get filepath of class on system or false if it does not exist
61+
*
62+
* @param string $className
63+
* @return string|bool
64+
*/
65+
public function findFile($className);
5866
}

0 commit comments

Comments
 (0)