Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/merchant_beta' into merchant_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov committed Oct 13, 2015
2 parents e9b958a + c8ba429 commit bb5836e
Show file tree
Hide file tree
Showing 23 changed files with 223 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ define(
var countryId = $('select[name="shippingAddress[country_id]"]').val();
var validationResult = postcodeValidator.validate(postcodeElement.value(), countryId);

postcodeElement.error(null);
postcodeElement.warn(null);
if (!validationResult) {
var errorMessage = $t('Invalid Zip/Postal code for current country!');
var warnMessage = $t('Provided Zip/Postal Code seems to be invalid.');
if (postcodeValidator.validatedPostCodeExample.length) {
errorMessage += $t(' Example: ') + postcodeValidator.validatedPostCodeExample.join('; ');
warnMessage += $t(' Example: ') + postcodeValidator.validatedPostCodeExample.join('; ') + '. ';
}
postcodeElement.error(errorMessage);
warnMessage += $t('If you believe it is the right one you can ignore this notice.');
postcodeElement.warn(warnMessage);
}
return validationResult;
},
Expand Down
16 changes: 13 additions & 3 deletions app/code/Magento/Customer/Model/Address/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function setStreet($street)
}

/**
* Enforce format of the street field
* Enforce format of the street field or other multiline custom attributes
*
* @param array|string $key
* @param null $value
Expand All @@ -263,12 +263,22 @@ public function setData($key, $value = null)
{
if (is_array($key)) {
$key = $this->_implodeArrayField($key);
} elseif (is_array($value)) {
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$value = $this->_implodeArrayValues($value);
}
return parent::setData($key, $value);
}

/**
* Check that address can have multiline attribute by this code (as street or some custom attribute)
* @param string $code
* @return bool
*/
protected function isAddressMultilineAttribute($code)
{
return $code == 'street' || in_array($code, $this->getCustomAttributesCodes());
}

/**
* Implode value of the array field, if it is present among other fields
*
Expand All @@ -278,7 +288,7 @@ public function setData($key, $value = null)
protected function _implodeArrayField(array $data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
if (is_array($value) && $this->isAddressMultilineAttribute($key)) {
$data[$key] = $this->_implodeArrayValues($data[$key]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public function testSetData()
*/
public function testSetDataWithMultidimensionalArray()
{
$this->markTestSkipped('Need to revert changes from MAGETWO-39106 and then modify this test.');
$expected = [
'key' => 'value',
'array' => 'value1',
Expand All @@ -266,10 +267,10 @@ public function testSetDataWithMultidimensionalArray()
public function testSetDataWithValue()
{
$value = [
'key' => 'value',
'street' => 'value',
];

$this->model->setData('key', $value);
$this->model->setData('street', $value);
$this->assertEquals($value, $this->model->getData());
}

Expand Down
20 changes: 16 additions & 4 deletions app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testCollectItemNoDiscount()
->getMock();
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
->getMock();
$addressMock->expects($this->any())
->method('getQuote')
Expand All @@ -124,6 +124,9 @@ public function testCollectItemNoDiscount()
$addressMock->expects($this->any())
->method('getShippingAmount')
->willReturn(true);
$addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);

$this->assertInstanceOf(
'Magento\SalesRule\Model\Quote\Discount',
Expand Down Expand Up @@ -165,7 +168,7 @@ public function testCollectItemHasParent()
->getMock();
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
->getMock();
$addressMock->expects($this->any())
->method('getQuote')
Expand All @@ -176,6 +179,9 @@ public function testCollectItemHasParent()
$addressMock->expects($this->any())
->method('getShippingAmount')
->willReturn(true);
$addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);

$this->assertInstanceOf(
'Magento\SalesRule\Model\Quote\Discount',
Expand Down Expand Up @@ -249,7 +255,7 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte
->getMock();
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
->getMock();
$addressMock->expects($this->any())
->method('getQuote')
Expand All @@ -260,6 +266,9 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte
$addressMock->expects($this->any())
->method('getShippingAmount')
->willReturn(true);
$addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);

$this->assertInstanceOf(
'Magento\SalesRule\Model\Quote\Discount',
Expand Down Expand Up @@ -368,7 +377,7 @@ public function testCollectItemHasNoChildren()
->getMock();
$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup'])
->setMethods(['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes'])
->getMock();
$addressMock->expects($this->any())
->method('getQuote')
Expand All @@ -379,6 +388,9 @@ public function testCollectItemHasNoChildren()
$addressMock->expects($this->any())
->method('getShippingAmount')
->willReturn(true);
$addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);

$this->assertInstanceOf(
'Magento\SalesRule\Model\Quote\Discount',
Expand Down
5 changes: 4 additions & 1 deletion app/code/Magento/SalesRule/Test/Unit/Model/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,17 @@ protected function getAddressMock($shippingAmount = null)

$addressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getShippingAmountForDiscount', 'getQuote'])
->setMethods(['getShippingAmountForDiscount', 'getQuote', 'getCustomAttributesCodes'])
->getMock();
$addressMock->expects($this->any())
->method('getShippingAmountForDiscount')
->willReturn($shippingAmount);
$addressMock->expects($this->any())
->method('getQuote')
->willReturn($quoteMock);
$addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);
return $addressMock;
}

Expand Down
21 changes: 19 additions & 2 deletions app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/TaxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,21 @@ public function testMapQuoteExtraTaxables($itemData, $addressData)

$address = $this->getMockBuilder('\Magento\Quote\Model\Quote\Address')
->disableOriginalConstructor()
->setMethods(['getAssociatedTaxables', 'getQuote', 'getBillingAddress', 'getRegionId', '__wakeup'])
->setMethods(
[
'getAssociatedTaxables',
'getQuote',
'getBillingAddress',
'getRegionId',
'__wakeup',
'getCustomAttributesCodes'
]
)
->getMock();
$address
->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);
$quote
->expects($this->any())
->method('getBillingAddress')
Expand Down Expand Up @@ -596,7 +609,7 @@ public function testFetch($appliedTaxesData, $addressData)
'\Magento\Quote\Model\Quote\Address',
[
'getAppliedTaxes', 'getQuote', 'getAllItems', 'getGrandTotal', '__wakeup',
'addTotal', 'getTaxAmount'
'addTotal', 'getTaxAmount', 'getCustomAttributesCodes'
],
[],
'',
Expand Down Expand Up @@ -626,6 +639,10 @@ public function testFetch($appliedTaxesData, $addressData)
->expects($this->any())
->method('getTaxAmount')
->will($this->returnValue(8));
$address
->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);

$addressData["cached_items_all"] = $items;
foreach ($addressData as $key => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define([
description: '',
label: '',
error: '',
warn: '',
notice: '',
customScope: '',
additionalClasses: {},
Expand Down Expand Up @@ -67,7 +68,7 @@ define([

this._super();

this.observe('error disabled focused preview visible value')
this.observe('error disabled focused preview visible value warn')
.observe({
'required': !!rules['required-entry']
});
Expand Down Expand Up @@ -115,6 +116,7 @@ define([
_.extend(this.additionalClasses, {
required: this.required,
_error: this.error,
_warn: this.warn,
_disabled: this.disabled
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<!-- ko if: element.error() -->
<div class="mage-error" data-bind="attr: { for: element.uid }, text: element.error" generated="true"></div>
<!-- /ko -->

<!-- ko if: element.warn() -->
<div class="message warning" generated="true"><span data-bind="text: element.warn"></span></div>
<!-- /ko -->
</div>
</div>
<!-- /ko -->
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ protected function setupAddressMock($itemMock)
'__wakeup',
'getAllItems',
'getQuote',
'getCustomAttributesCodes'
],
[],
'',
Expand All @@ -136,6 +137,7 @@ protected function setupAddressMock($itemMock)

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

return $addressMock;
}
Expand Down
5 changes: 5 additions & 0 deletions app/design/frontend/Magento/blank/web/css/source/_forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ fieldset.field {
white-space: nowrap;
}
}
.message {
&.warning {
margin-top: @indent__s;
}
}
}

div.mage-error[generated] {
Expand Down
17 changes: 12 additions & 5 deletions app/design/frontend/Magento/luma/web/css/source/_forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,18 @@ fieldset.field {
border: 0;
padding: 0;
}
.field.date {
.time-picker {
white-space: nowrap;
margin-top: @indent__s;
display: inline-block;
.field {
&.date {
.time-picker {
white-space: nowrap;
margin-top: @indent__s;
display: inline-block;
}
}
.message {
&.warning {
margin-top: @indent__s;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testGenerate()
protected function mockDefinedClassesCall()
{
$this->definedClassesMock->expects($this->at(0))
->method('classLoadable')
->method('isClassLoadable')
->with($this->getSourceClassName())
->willReturn(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ public function setPsr4($nsPrefix, $paths);
* @return bool
*/
public function loadClass($className);

/**
* Get filepath of class on system or false if it does not exist
*
* @param string $className
* @return string|bool
*/
public function findFile($className);
}
Loading

0 comments on commit bb5836e

Please sign in to comment.