Skip to content

Commit d7a45d5

Browse files
committed
Fixed Failing Unit Test Cases
1 parent 2c4dce5 commit d7a45d5

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

app/code/Magento/Checkout/Model/Sidebar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function normalize($itemQty)
135135
}
136136

137137
$filter = new LocalizedToNormalized(
138-
['locale' => $this->resolver->getLocale(), 'decimal_style' => NumberFormatter::DECIMAL]
138+
['locale' => $this->resolver->getLocale(), 'type' => NumberFormatter::TYPE_DOUBLE]
139139
);
140140
return $filter->filter((string)$itemQty);
141141
}

lib/internal/Magento/Framework/Filter/LocalizedToNormalized.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LocalizedToNormalized implements FilterInterface
2121
'locale' => null,
2222
'date_format' => null,
2323
'precision' => null,
24-
'decimal_style' => null,
24+
'type' => null,
2525
];
2626

2727
/**
@@ -70,10 +70,11 @@ public function filter($value)
7070
if (is_numeric($value)) {
7171
$numberParse = new NumberParse(
7272
$this->_options['locale'],
73-
empty($this->_options['decimal_style'])
74-
? NumberFormatter::PATTERN_DECIMAL
75-
: $this->_options['decimal_style']
73+
empty($this->_options['type'])
74+
? NumberFormatter::TYPE_DOUBLE
75+
: $this->_options['type']
7676
);
77+
7778
return (string)$numberParse->filter($value);
7879
} elseif ($this->_options['date_format'] === null && strpos($value, ':') !== false) {
7980
$formatter = new IntlDateFormatter(

lib/internal/Magento/Framework/Filter/Test/Unit/LocalizedToNormalizedTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function localizedToNormalizedDataProvider()
4040
'locale' => 'nl',
4141
'date_format' => null,
4242
'precision' => null,
43-
'decimal_style' => NumberFormatter::PATTERN_DECIMAL
43+
'type' => NumberFormatter::TYPE_DOUBLE
4444
],
4545
"0.5"
4646
],
@@ -50,17 +50,27 @@ public static function localizedToNormalizedDataProvider()
5050
'locale' => 'en',
5151
'date_format' => null,
5252
'precision' => null,
53-
'decimal_style' => ' '
53+
'type' => ' '
5454
],
5555
"0.5"
5656
],
5757
'3' => [
58+
"2",
59+
[
60+
'locale' => 'en',
61+
'date_format' => null,
62+
'precision' => null,
63+
'type' => ''
64+
],
65+
"2"
66+
],
67+
'4' => [
5868
'2014-03-30',
5969
[
6070
'locale' => 'en',
6171
'date_format' => 'Y-M-d',
6272
'precision' => null,
63-
'decimal_style' => ''
73+
'type' => ''
6474
],
6575
[
6676
"date_format" => "Y-M-d",

0 commit comments

Comments
 (0)