Skip to content

Commit fb7cbc8

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-67358
2 parents 5845b9c + e0e9ed0 commit fb7cbc8

File tree

150 files changed

+3937
-949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+3937
-949
lines changed

app/code/Magento/Braintree/Gateway/Config/Config.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,12 @@ public function __construct(
7272
*/
7373
public function getCountrySpecificCardTypeConfig()
7474
{
75-
$countriesCardTypes = $this->serializer->unserialize($this->getValue(self::KEY_COUNTRY_CREDIT_CARD));
76-
77-
return is_array($countriesCardTypes) ? $countriesCardTypes : [];
75+
$countryCardTypes = $this->getValue(self::KEY_COUNTRY_CREDIT_CARD);
76+
if (!$countryCardTypes) {
77+
return [];
78+
}
79+
$countryCardTypes = $this->serializer->unserialize($countryCardTypes);
80+
return is_array($countryCardTypes) ? $countryCardTypes : [];
7881
}
7982

8083
/**

app/code/Magento/Braintree/Model/Adminhtml/System/Config/CountryCreditCard.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ public function beforeSave()
8989
*/
9090
public function afterLoad()
9191
{
92-
$value = $this->serializer->unserialize($this->getValue());
93-
if (is_array($value)) {
94-
$value = $this->encodeArrayFieldValue($value);
95-
$this->setValue($value);
92+
if ($this->getValue()) {
93+
$value = $this->serializer->unserialize($this->getValue());
94+
if (is_array($value)) {
95+
$this->setValue($this->encodeArrayFieldValue($value));
96+
}
9697
}
9798
return $this;
9899
}

app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryCreditCardTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,30 @@ public function beforeSaveDataProvider()
150150
}
151151

152152
/**
153-
* @dataProvider afterLoadDataProvider
154153
* @param string $encodedValue
155154
* @param array|null $value
156155
* @param array $hashData
157156
* @param array|null $expected
157+
* @param int $unserializeCalledNum
158+
* @dataProvider afterLoadDataProvider
158159
*/
159-
public function testAfterLoad($encodedValue, $value, array $hashData, $expected)
160-
{
160+
public function testAfterLoad(
161+
$encodedValue,
162+
$value,
163+
array $hashData,
164+
$expected,
165+
$unserializeCalledNum = 1
166+
) {
161167
$this->model->setValue($encodedValue);
162168
$index = 0;
163169
foreach ($hashData as $hash) {
164-
$this->mathRandomMock->expects(static::at($index))
170+
$this->mathRandomMock->expects($this->at($index))
165171
->method('getUniqueHash')
166172
->willReturn($hash);
167173
$index++;
168174
}
169175

170-
$this->serializerMock->expects($this->once())
176+
$this->serializerMock->expects($this->exactly($unserializeCalledNum))
171177
->method('unserialize')
172178
->with($encodedValue)
173179
->willReturn($value);
@@ -178,6 +184,7 @@ public function testAfterLoad($encodedValue, $value, array $hashData, $expected)
178184

179185
/**
180186
* Get data to test saved credit cards types
187+
*
181188
* @return array
182189
*/
183190
public function afterLoadDataProvider()
@@ -193,7 +200,8 @@ public function afterLoadDataProvider()
193200
'encoded' => '',
194201
'value' => null,
195202
'randomHash' => [],
196-
'expected' => null
203+
'expected' => null,
204+
0
197205
],
198206
'valid data' => [
199207
'encoded' => '{"US":["AE","VI","MA"],"AF":["AE","MA"]}',

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ define(
3636
braintreeDeviceData: null,
3737
paymentMethodNonce: null,
3838
lastBillingAddress: null,
39+
ccCode: null,
40+
ccMessageContainer: null,
3941
validatorManager: validatorManager,
4042
code: 'braintree',
4143

@@ -138,9 +140,39 @@ define(
138140
return;
139141
}
140142

143+
this.restoreMessageContainer();
144+
this.restoreCode();
145+
146+
/**
147+
* Define onReady callback
148+
*/
149+
braintree.onReady = function () {};
141150
this.initBraintree();
142151
},
143152

153+
/**
154+
* Restore original message container for cc-form component
155+
*/
156+
restoreMessageContainer: function () {
157+
this.messageContainer = this.ccMessageContainer;
158+
},
159+
160+
/**
161+
* Restore original code for cc-form component
162+
*/
163+
restoreCode: function () {
164+
this.code = this.ccCode;
165+
},
166+
167+
/** @inheritdoc */
168+
initChildren: function () {
169+
this._super();
170+
this.ccMessageContainer = this.messageContainer;
171+
this.ccCode = this.code;
172+
173+
return this;
174+
},
175+
144176
/**
145177
* Init config
146178
*/

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ define([
5252
var self = this;
5353

5454
/**
55-
* Define already callback
55+
* Define onReady callback
5656
*/
5757
Braintree.onReady = function () {
5858
self.getPaymentMethodNonce();
@@ -78,6 +78,7 @@ define([
7878
formComponent.setPaymentMethodNonce(response.paymentMethodNonce);
7979
formComponent.additionalData['public_hash'] = self.publicHash;
8080
formComponent.code = self.code;
81+
formComponent.messageContainer = self.messageContainer;
8182
formComponent.placeOrder();
8283
});
8384
})

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@
139139
<button class="action primary checkout"
140140
type="submit"
141141
data-bind="
142-
click: placeOrderClick,
143-
attr: {title: $t('Place Order')}
144-
">
142+
click: placeOrderClick,
143+
attr: {title: $t('Place Order')},
144+
css: {disabled: !isPlaceOrderActionAllowed()},
145+
enable: isActive()
146+
"
147+
disabled>
145148
<span data-bind="i18n: 'Place Order'"></span>
146149
</button>
147150
</div>

app/code/Magento/Bundle/Model/Product/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected function getBundleSelectionIds(\Magento\Catalog\Model\Product $product
166166
$customOption = $product->getCustomOption('bundle_selection_ids');
167167
if ($customOption) {
168168
$selectionIds = $this->serializer->unserialize($customOption->getValue());
169-
if (!empty($selectionIds) && is_array($selectionIds)) {
169+
if (is_array($selectionIds) && !empty($selectionIds)) {
170170
return $selectionIds;
171171
}
172172
}

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function execute($entity, $arguments = [])
6666
$options = $bundleProductOptions ?: [];
6767
foreach ($options as $option) {
6868
$this->optionRepository->save($entity, $option);
69-
$entity->setCopyFromView(false);
7069
}
70+
$entity->setCopyFromView(false);
7171
}
7272
return $entity;
7373
}

app/code/Magento/Bundle/Observer/LoadProductOptionsObserver.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)