Skip to content

Commit e045c32

Browse files
committed
2 parents 1291747 + 938313e commit e045c32

File tree

103 files changed

+2670
-734
lines changed

Some content is hidden

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

103 files changed

+2670
-734
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/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/Observer/LoadProductOptionsObserver.php

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

0 commit comments

Comments
 (0)