Skip to content

Commit 10ff4f8

Browse files
Merge pull request #444 from magento-firedrakes/bugfixes
Fixed issues: - MAGETWO-58349: [DX] Resource model does not reflect model load process flow. - MAGETWO-57866: [Firefox] No JS validation for Credit card and expiration date on backend - MAGETWO-55346: [GitHub] Setting SKU mask as empty crashes product Javascript in backend #5618 - MAGETWO-59145: Mark CreateConfigurableProductEntityTest as not stable
2 parents 12602c4 + eceac0c commit 10ff4f8

File tree

36 files changed

+457
-133
lines changed

36 files changed

+457
-133
lines changed

app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
3535
</label>
3636
<div class="admin__field-control">
3737
<select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]"
38-
class="required-entry validate-cc-type-select admin__control-select">
39-
<option value=""></option>
38+
class="admin__control-select"
39+
data-validate="{
40+
'required':true,
41+
'validate-cc-type-select':'#<?php /* @noEscape */ echo $code; ?>_cc_number'
42+
}">
43+
<option value=""><?php echo $block->escapeHtml(__('Please Select')); ?></option>
4044
<?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?>
4145
<option value="<?php echo $block->escapeHtml($typeCode); ?>"
4246
<?php if ($typeCode == $ccType): ?>selected="selected"<?php endif; ?>>
@@ -46,27 +50,37 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
4650
</select>
4751
</div>
4852
</div>
53+
4954
<div class="admin__field _required">
5055
<label for="<?php /* @noEscape */ echo $code; ?>_cc_number" class="admin__field-label">
5156
<span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span>
5257
</label>
53-
5458
<div class="admin__field-control">
5559
<input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number"
5660
name="payment[cc_number]"
57-
class="input-text required-entry validate-cc-number admin__control-text"
61+
data-validate="{
62+
'required-number':true,
63+
'validate-cc-number':'#<?php /* @noEscape */ echo $code; ?>_cc_type',
64+
'validate-cc-type':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
65+
}"
66+
class="admin__control-text"
5867
value="<?php /* @noEscape */ echo $block->getInfoData('cc_number'); ?>"/>
5968
</div>
6069
</div>
61-
<div class="admin__field _required">
70+
71+
<div class="admin__field _required field-date" id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div">
6272
<label for="<?php /* @noEscape */ echo $code; ?>_expiration" class="admin__field-label">
6373
<span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span>
6474
</label>
6575

6676
<div class="admin__field-control">
6777
<select id="<?php /* @noEscape */ echo $code; ?>_expiration"
6878
name="payment[cc_exp_month]"
69-
class="validate-cc-exp required-entry admin__control-select admin__control-select-month">
79+
class="admin__control-select admin__control-select-month"
80+
data-validate="{
81+
'required':true,
82+
'validate-cc-exp':'#<?php /* @noEscape */ echo $code; ?>_expiration_yr'
83+
}">
7084
<?php foreach ($block->getCcMonths() as $k => $v): ?>
7185
<option value="<?php echo $block->escapeHtml($k); ?>"
7286
<?php if ($k == $ccExpMonth): ?>selected="selected"<?php endif; ?>>
@@ -76,7 +90,9 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
7690
</select>
7791
<select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr"
7892
name="payment[cc_exp_year]"
79-
class="required-entry admin__control-select admin__control-select-year">
93+
class="admin__control-select admin__control-select-year"
94+
data-container="<?php /* @noEscape */ echo $code; ?>-cc-year"
95+
data-validate="{required:true}">
8096
<?php foreach ($block->getCcYears() as $k => $v): ?>
8197
<option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>"
8298
<?php if ($k == $ccExpYear): ?>selected="selected"<?php endif; ?>>
@@ -86,17 +102,27 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
86102
</select>
87103
</div>
88104
</div>
105+
89106
<?php if ($block->hasVerification()): ?>
90-
<div class="admin__field _required">
91-
<label for="<?php /* @noEscape */ echo $code; ?>_cc_cid">
107+
<div class="admin__field _required field-cvv">
108+
<label class="admin__field-label"
109+
for="<?php /* @noEscape */ echo $code; ?>_cc_cid"
110+
id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div">
92111
<span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span>
93112
</label>
94113

95114
<div class="admin__field-control">
96115
<input type="text"
97-
class="required-entry input-text validate-cc-cvn admin__control-text"
116+
data-container="<?php /* @noEscape */ echo $code; ?>-cc-cvv"
117+
title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>"
118+
class="admin__control-text cvv"
98119
id="<?php /* @noEscape */ echo $code; ?>_cc_cid" name="payment[cc_cid]"
99-
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"/>
120+
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"
121+
data-validate="{
122+
'required-number':true,
123+
'validate-cc-cvn':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
124+
}"
125+
autocomplete="off"/>
100126
</div>
101127
</div>
102128
<?php endif; ?>
@@ -105,7 +131,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
105131
require([
106132
'prototype',
107133
'Magento_Sales/order/create/scripts',
108-
"Magento_Sales/order/create/form",
134+
'Magento_Sales/order/create/form',
109135
'Magento_Authorizenet/js/direct-post'
110136
], function(){
111137

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -831,20 +831,6 @@ private function getStatusStockProviderData($extensionAttributesMock)
831831
];
832832
}
833833

834-
public function testStatusAfterLoad()
835-
{
836-
$this->resource->expects($this->once())->method('load')->with($this->model, 1, null);
837-
$this->eventManagerMock->expects($this->exactly(4))->method('dispatch');
838-
$this->model->load(1);
839-
$this->assertEquals(
840-
Status::STATUS_ENABLED,
841-
$this->model->getData(\Magento\Catalog\Model\Product::STATUS)
842-
);
843-
$this->assertFalse($this->model->hasDataChanges());
844-
$this->model->setStatus(Status::STATUS_DISABLED);
845-
$this->assertTrue($this->model->hasDataChanges());
846-
}
847-
848834
/**
849835
* Test retrieving price Info
850836
*/

app/code/Magento/Catalog/view/adminhtml/web/js/components/import-handler.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66
define([
7+
'underscore',
78
'Magento_Ui/js/form/element/textarea'
8-
], function (Textarea) {
9+
], function (_, Textarea) {
910
'use strict';
1011

1112
return Textarea.extend({
@@ -123,24 +124,21 @@ define([
123124
* Update field value, if it's allowed
124125
*/
125126
updateValue: function () {
126-
var str = this.mask,
127+
var str = this.mask || '',
127128
nonEmptyValueFlag = false,
128-
placeholder,
129-
property,
130129
tmpElement;
131130

132131
if (!this.allowImport) {
133132
return;
134133
}
135134

136-
for (property in this.values) {
137-
if (this.values.hasOwnProperty(property)) {
138-
placeholder = '';
139-
placeholder = placeholder.concat('{{', property, '}}');
140-
str = str.replace(placeholder, this.values[property]);
141-
nonEmptyValueFlag = nonEmptyValueFlag || !!this.values[property];
142-
}
135+
if (str) {
136+
_.each(this.values, function (propertyValue, propertyName) {
137+
str = str.replace('{{' + propertyName + '}}', propertyValue);
138+
nonEmptyValueFlag = nonEmptyValueFlag || !!propertyValue;
139+
});
143140
}
141+
144142
// strip tags
145143
tmpElement = document.createElement('div');
146144
tmpElement.innerHTML = str;

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ public function load($object, $entityId, $attributes = [])
950950
/**
951951
* Load object base row data
952952
*/
953+
$object->beforeLoad($entityId);
953954
$select = $this->_getLoadRowSelect($object, $entityId);
954955
$row = $this->getConnection()->fetchRow($select);
955956

@@ -962,11 +963,10 @@ public function load($object, $entityId, $attributes = [])
962963
$this->loadAttributesMetadata($attributes);
963964

964965
$this->_loadModelAttributes($object);
965-
966-
$object->setOrigData();
967-
968966
$this->_afterLoad($object);
969-
967+
$object->afterLoad();
968+
$object->setOrigData();
969+
$object->setHasDataChanges(false);
970970
\Magento\Framework\Profiler::stop('EAV:load_entity');
971971
return $this;
972972
}

app/code/Magento/Payment/view/adminhtml/web/transparent.js

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
define([
77
'jquery',
88
'mage/template',
9-
'Magento_Ui/js/modal/alert'
9+
'Magento_Ui/js/modal/alert',
10+
'Magento_Payment/js/model/credit-card-validation/validator'
1011
], function ($, mageTemplate, alert) {
1112
'use strict';
1213

1314
$.widget('mage.transparent', {
1415
options: {
16+
editFormSelector: '#edit_form',
1517
hiddenFormTmpl:
1618
'<form target="<%= data.target %>" action="<%= data.action %>"' +
1719
'method="POST" hidden' +
@@ -33,37 +35,51 @@ define([
3335
* @private
3436
*/
3537
_create: function () {
38+
this.hiddenFormTmpl = mageTemplate(this.options.hiddenFormTmpl);
3639

37-
/**
38-
* @param {Object} event
39-
* @param {String} method
40-
*/
41-
var prepare = function (event, method) {
42-
if (method === this.options.gateway) {
43-
$('#edit_form')
44-
.off('submitOrder')
45-
.on('submitOrder.' + this.options.gateway, this._orderSave.bind(this));
46-
} else {
47-
$('#edit_form')
48-
.off('submitOrder.' + this.options.gateway);
49-
}
50-
},
51-
$editForm = $('#edit_form');
40+
$(this.options.editFormSelector).on('changePaymentMethod', this._setPlaceOrderHandler.bind(this));
41+
$(this.options.editFormSelector).trigger('changePaymentMethod', [
42+
$(this.options.editFormSelector).find(':radio[name="payment[method]"]:checked').val()
43+
]);
44+
},
5245

53-
this.hiddenFormTmpl = mageTemplate(this.options.hiddenFormTmpl);
54-
$editForm.on('changePaymentMethod', prepare.bind(this));
55-
56-
$editForm.trigger(
57-
'changePaymentMethod',
58-
[
59-
$editForm.find(':radio[name="payment[method]"]:checked').val()
60-
]
61-
);
46+
/**
47+
* Handler for form submit.
48+
*
49+
* @param {Object} event
50+
* @param {String} method
51+
*/
52+
_setPlaceOrderHandler: function (event, method) {
53+
if (method === this.options.gateway) {
54+
$(this.options.editFormSelector)
55+
.off('submitOrder')
56+
.on('submitOrder.' + this.options.gateway, this._placeOrderHandler.bind(this));
57+
} else {
58+
$(this.options.editFormSelector)
59+
.off('submitOrder.' + this.options.gateway);
60+
}
61+
},
62+
63+
/**
64+
* Handler for form submit to call gateway for credit card validation.
65+
*
66+
* @return {Boolean}
67+
* @private
68+
*/
69+
_placeOrderHandler: function () {
70+
if ($(this.options.editFormSelector).valid()) {
71+
this._orderSave();
72+
} else {
73+
$('body').trigger('processStop');
74+
}
75+
76+
return false;
6277
},
6378

6479
/**
65-
* handler for Place Order button to call gateway for credit card validation
66-
* Save order and generate post data for gateway call
80+
* Handler for Place Order button to call gateway for credit card validation.
81+
* Save order and generate post data for gateway call.
82+
*
6783
* @private
6884
*/
6985
_orderSave: function () {
@@ -99,7 +115,8 @@ define([
99115
},
100116

101117
/**
102-
* Post data to gateway for credit card validation
118+
* Post data to gateway for credit card validation.
119+
*
103120
* @param {Object} response
104121
* @private
105122
*/
@@ -136,7 +153,7 @@ define([
136153
},
137154

138155
/**
139-
* Add credit card fields to post data for gateway
156+
* Add credit card fields to post data for gateway.
140157
*
141158
* @param {Object} response
142159
* @private

app/code/Magento/Paypal/view/adminhtml/templates/transparent/form.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ $ccExpMonth = $block->getInfoData('cc_exp_month');
129129
<?php endif; ?>
130130

131131
<?php if($block->isVaultEnabled()): ?>
132-
<div class="field-tooltip-content">
132+
<div class="admin__field admin__field-option field-tooltip-content">
133133
<input type="checkbox"
134134
id="<?php /* @noEscape */ echo $code; ?>_vault"
135135
name="payment[is_active_payment_token_enabler]"
136136
class="admin__control-checkbox"/>
137-
<label class="label" for="<?php /* @noEscape */ echo $code; ?>_vault">
137+
<label class="admin__field-label" for="<?php /* @noEscape */ echo $code; ?>_vault">
138138
<span><?php echo $block->escapeHtml('Save for later use.'); ?></span>
139139
</label>
140140
</div>

app/code/Magento/SalesSequence/Test/Unit/Model/ResourceModel/MetaTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function testLoadBy()
161161
->willReturn($metaId);
162162
$this->metaFactory->expects($this->once())->method('create')->willReturn($this->meta);
163163
$this->stepCheckSaveWithActiveProfile($metaData);
164+
$this->meta->expects($this->once())->method('beforeLoad');
164165
$this->assertEquals($this->meta, $this->resource->loadByEntityTypeAndStore($entityType, $storeId));
165166
}
166167

@@ -177,7 +178,5 @@ private function stepCheckSaveWithActiveProfile($metaData)
177178
->method('quoteIdentifier');
178179
$this->connectionMock->expects($this->once())->method('fetchRow')->willReturn($metaData);
179180
$this->resourceProfile->expects($this->once())->method('loadActiveProfile')->willReturn($this->profile);
180-
$this->meta->expects($this->at(0))->method('setData')->with($metaData);
181-
$this->meta->expects($this->at(2))->method('setData')->with('active_profile', $this->profile);
182181
}
183182
}

app/code/Magento/SalesSequence/Test/Unit/Model/ResourceModel/ProfileTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testLoadActiveProfile()
156156
$this->connectionMock->expects($this->any())
157157
->method('quoteIdentifier');
158158
$this->connectionMock->expects($this->once())->method('fetchRow')->willReturn($profileData);
159-
$this->profile->expects($this->at(0))->method('setData')->with($profileData);
159+
$this->profile->expects($this->at(1))->method('setData')->with($profileData);
160160
$this->assertEquals($this->profile, $this->resource->loadActiveProfile($metaId));
161161
}
162162
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/ConfigData.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,16 @@
2323
<item name="value" xsi:type="number">0</item>
2424
</field>
2525
</dataset>
26+
<dataset name="empty_product_mask_sku">
27+
<field name="catalog/fields_masks/sku" xsi:type="array">
28+
<item name="value" xsi:type="string"/>
29+
</field>
30+
</dataset>
31+
<dataset name="empty_product_mask_sku_rollback">
32+
<field name="catalog/fields_masks/sku" xsi:type="array">
33+
<item name="value" xsi:type="string">{{name}}</item>
34+
<item name="inherit" xsi:type="number">1</item>
35+
</field>
36+
</dataset>
2637
</repository>
2738
</config>

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,5 +461,22 @@
461461
<data name="product/data/country_of_manufacture" xsi:type="string">Antarctica</data>
462462
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
463463
</variation>
464+
<variation name="CreateSimpleProductEntityWithEmptySkuMaskTest1" summary="Create Simple Product Entity With Empty Sku Mask" ticketId="MAGETWO-58951">
465+
<data name="configData" xsi:type="string">empty_product_mask_sku</data>
466+
<data name="description" xsi:type="string">Create product with custom options(fixed price)</data>
467+
<data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data>
468+
<data name="product/data/name" xsi:type="string">Simple Product %isolation%</data>
469+
<data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data>
470+
<data name="product/data/price/value" xsi:type="string">10000</data>
471+
<data name="product/data/weight" xsi:type="string">50</data>
472+
<data name="product/data/quantity_and_stock_status/qty" xsi:type="string">657</data>
473+
<data name="product/data/checkout_data/dataset" xsi:type="string">simple_drop_down_with_one_option_fixed_price</data>
474+
<data name="product/data/price/dataset" xsi:type="string">drop_down_with_one_option_fixed_price</data>
475+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
476+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" />
477+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCategory" />
478+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductPage" />
479+
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInCart" />
480+
</variation>
464481
</testCase>
465482
</config>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductPage" />
111111
</variation>
112112
<variation name="CreateConfigurableProductEntityTestVariation6" summary="Create Configurable Product with Creating New Category and New Attribute (Required Fields Only)" ticketId="MAGETWO-13361">
113-
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
113+
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
114114
<data name="product/data/configurable_attributes_data/dataset" xsi:type="string">two_searchable_options</data>
115115
<data name="product/data/name" xsi:type="string">Configurable Product %isolation%</data>
116116
<data name="product/data/sku" xsi:type="string">configurable_sku_%isolation%</data>

0 commit comments

Comments
 (0)