Skip to content

Commit 5fdd20b

Browse files
author
Joan He
committed
Merge remote-tracking branch 'kiwis/develop' into develop
2 parents c46a899 + 0fcdcaa commit 5fdd20b

File tree

12 files changed

+207
-19
lines changed

12 files changed

+207
-19
lines changed

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ define([
184184
var type = $(element).data('priceType'),
185185
amount = parseFloat($(element).data('priceAmount'));
186186

187-
if (type && amount) {
187+
if (type && !_.isNaN(amount)) {
188188
prices[type] = {
189189
amount: amount
190190
};

app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurablePriceResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $produ
4848
$productPrice = $this->priceResolver->resolvePrice($subProduct);
4949
$price = $price ? min($price, $productPrice) : $productPrice;
5050
}
51-
if (!$price) {
51+
if ($price === null) {
5252
throw new \Magento\Framework\Exception\LocalizedException(
53-
__('Configurable product "%1" do not have sub-products', $product->getName())
53+
__('Configurable product "%1" does not have sub-products', $product->getName())
5454
);
5555
}
5656
return (float)$price;

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ protected function setUp()
6565
false
6666
);
6767

68-
$this->productOptionExtensionAttributes = $this->getMockBuilder(ProductOptionExtensionAttributes::class)
69-
->disableOriginalConstructor()
70-
->setMethods(['setConfigurableItemOptions'])
71-
->getMock();
68+
$this->productOptionExtensionAttributes = $this->getMockForAbstractClass(
69+
ProductOptionExtensionAttributes::class,
70+
[],
71+
'',
72+
false,
73+
true,
74+
true,
75+
['setConfigurableItemOptions']
76+
);
7277

7378
$this->model = new \Magento\ConfigurableProduct\Model\Quote\Item\CartItemProcessor(
7479
$this->objectFactoryMock,
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Test\Unit\Pricing\Price;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
10+
class ConfigurablePriceResolverTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver
14+
*/
15+
protected $resolver;
16+
17+
/**
18+
* @var PHPUnit_Framework_MockObject_MockObject | \Magento\ConfigurableProduct\Model\Product\Type\Configurable
19+
*/
20+
protected $configurable;
21+
22+
/**
23+
* @var PHPUnit_Framework_MockObject_MockObject | \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface
24+
*/
25+
protected $priceResolver;
26+
27+
protected function setUp()
28+
{
29+
$className = 'Magento\ConfigurableProduct\Model\Product\Type\Configurable';
30+
$this->configurable = $this->getMock($className, ['getUsedProducts'], [], '', false);
31+
32+
$className = 'Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface';
33+
$this->priceResolver = $this->getMockForAbstractClass($className, [], '', false, true, true, ['resolvePrice']);
34+
35+
$objectManager = new ObjectManager($this);
36+
$this->resolver = $objectManager->getObject(
37+
'Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver',
38+
[
39+
'priceResolver' => $this->priceResolver,
40+
'configurable' => $this->configurable,
41+
]
42+
);
43+
}
44+
45+
/**
46+
* situation: There are no used products, thus there are no prices
47+
*
48+
* @expectedException \Magento\Framework\Exception\LocalizedException
49+
*/
50+
public function testResolvePriceWithNoPrices()
51+
{
52+
$product = $this->getMockForAbstractClass(
53+
'Magento\Framework\Pricing\SaleableInterface',
54+
[],
55+
'',
56+
false,
57+
true,
58+
true,
59+
['getName']
60+
);
61+
$product->expects($this->once())->method('getName')->willReturn('Kiwi');
62+
63+
$this->configurable->expects($this->once())->method('getUsedProducts')->willReturn([]);
64+
65+
$this->resolver->resolvePrice($product);
66+
}
67+
68+
/**
69+
* situation: one product is supplying the price, which could be a price of zero (0)
70+
*
71+
* @dataProvider testResolvePriceDataProvider
72+
*/
73+
public function testResolvePrice($expectedValue)
74+
{
75+
$price = $expectedValue;
76+
77+
$product = $this->getMockForAbstractClass(
78+
'Magento\Framework\Pricing\SaleableInterface',
79+
[],
80+
'',
81+
false,
82+
true,
83+
true,
84+
['getName']
85+
);
86+
$product->expects($this->never())->method('getName');
87+
88+
$this->configurable->expects($this->once())->method('getUsedProducts')->willReturn([$product]);
89+
$this->priceResolver->expects($this->atLeastOnce())->method('resolvePrice')->willReturn($price);
90+
91+
$this->assertEquals($expectedValue, $this->resolver->resolvePrice($product));
92+
}
93+
94+
/**
95+
* @return array
96+
*/
97+
public function testResolvePriceDataProvider()
98+
{
99+
return [
100+
'price of zero' => [0.00],
101+
'price of five' => [5],
102+
];
103+
}
104+
}

app/code/Magento/ConfigurableProduct/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Summary,Summary
3030
"You need to choose options for your item.","You need to choose options for your item."
3131
"Some product variations fields are not valid.","Some product variations fields are not valid."
3232
"Configuration must have specified attributes","Configuration must have specified attributes"
33-
"Configurable product ""%1"" do not have sub-products","Configurable product ""%1"" do not have sub-products"
33+
"Configurable product ""%1"" does not have sub-products","Configurable product ""%1"" does not have sub-products"
3434
"This group contains attributes used in configurable products. Please move these attributes to another group and try again.","This group contains attributes used in configurable products. Please move these attributes to another group and try again."
3535
"This attribute is used in configurable products. You cannot remove it from the attribute set.","This attribute is used in configurable products. You cannot remove it from the attribute set."
3636
"Associated Products","Associated Products"

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ define([
2323
state: {},
2424
priceFormat: {},
2525
optionTemplate: '<%- data.label %>' +
26-
'<% if (data.finalPrice.value) { %>' +
26+
"<% if (typeof data.finalPrice.value !== 'undefined') { %>" +
2727
' <%- data.finalPrice.formatted %>' +
2828
'<% } %>',
2929
mediaGallerySelector: '[data-gallery-role=gallery-placeholder]',

app/code/Magento/Quote/Model/Quote/Address/Total.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public function getBaseTotalAmount($code)
114114
}
115115

116116
//@codeCoverageIgnoreStart
117+
117118
/**
118119
* Get all total amount values
119120
*
@@ -133,4 +134,33 @@ public function getAllBaseTotalAmounts()
133134
{
134135
return $this->baseTotalAmounts;
135136
}
137+
138+
//@codeCoverageIgnoreEnd
139+
140+
/**
141+
* Set the full info, which is used to capture tax related information.
142+
* If a string is used, it is assumed to be serialized.
143+
*
144+
* @param array|string $info
145+
* @return $this
146+
*/
147+
public function setFullInfo($info)
148+
{
149+
$this->setData('full_info', $info);
150+
return $this;
151+
}
152+
153+
/**
154+
* Returns the full info, which is used to capture tax related information.
155+
*
156+
* @return array
157+
*/
158+
public function getFullInfo()
159+
{
160+
$fullInfo = $this->getData('full_info');
161+
if (is_string($fullInfo)) {
162+
$fullInfo = unserialize($fullInfo);
163+
}
164+
return $fullInfo;
165+
}
136166
}

app/code/Magento/Quote/Test/Unit/Model/Quote/Address/TotalTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,48 @@ public function testGetBaseTotalAmountAbsent()
167167
{
168168
$this->assertEquals(0, $this->model->getBaseTotalAmount('great'));
169169
}
170+
171+
/**
172+
* Verify handling of serialized, non-serialized input into and out of getFullInfo()
173+
*
174+
* @param $input
175+
* @param $expected
176+
* @dataProvider getFullInfoDataProvider
177+
*/
178+
public function testGetFullInfo($input, $expected)
179+
{
180+
$this->model->setFullInfo($input);
181+
$this->assertEquals($expected, $this->model->getFullInfo());
182+
}
183+
184+
/**
185+
* @return array
186+
*/
187+
public function getFullInfoDataProvider()
188+
{
189+
$myArray = ['team' => 'kiwis'];
190+
$serializedInput = serialize($myArray);
191+
192+
return [
193+
'simple array' => [
194+
$myArray,
195+
$myArray,
196+
],
197+
198+
'serialized array' => [
199+
$serializedInput,
200+
$myArray,
201+
],
202+
203+
'null input/output' => [
204+
null,
205+
null,
206+
],
207+
208+
'float input' => [
209+
1.23,
210+
1.23,
211+
],
212+
];
213+
}
170214
}

app/code/Magento/Sales/view/adminhtml/templates/order/create/totals/tax.phtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ $taxAmount = $block->getTotal()->getValue();
1111
<?php if (($taxAmount == 0 && $this->helper('Magento\Tax\Helper\Data')->displayZeroTax()) || ($taxAmount > 0)): ?>
1212
<?php global $taxIter; $taxIter++; ?>
1313
<?php if ($this->helper('Magento\Tax\Helper\Data')->displayFullSummary()): ?>
14-
<?php $isTop = 1; ?>
15-
<?php foreach ($block->getTotal()->getFullInfo() as $info): ?>
14+
<?php $isTop = 1; ?>
15+
<?php foreach ($block->getTotal()->getFullInfo() as $info): ?>
1616
<?php if (isset($info['hidden']) && $info['hidden']) {
17-
continue;
18-
} ?>
17+
continue;
18+
} ?>
1919
<?php $percent = $info['percent']; ?>
2020
<?php $amount = $info['amount']; ?>
2121
<?php $rates = $info['rates']; ?>
@@ -39,7 +39,7 @@ $taxAmount = $block->getTotal()->getValue();
3939
<?php $isFirst = 0; ?>
4040
<?php $isTop = 0; ?>
4141
<?php endforeach; ?>
42-
<?php endforeach; ?>
42+
<?php endforeach; ?>
4343
<?php endif;?>
4444
<?php $class = "{$block->getTotal()->getCode()} " . ($this->helper('Magento\Tax\Helper\Data')->displayFullSummary() ? 'summary-total' : ''); ?>
4545
<tr<?php if ($this->helper('Magento\Tax\Helper\Data')->displayFullSummary()): ?> onclick="expandDetails(this, '.summary-details-<?php /* @escapeNotVerified */ echo $taxIter;?>')"<?php endif; ?> class="<?php /* @escapeNotVerified */ echo $class;?> row-totals">

app/code/Magento/SalesRule/Model/Rule/Metadata/ValueProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getMetadataValues(\Magento\SalesRule\Model\Rule $rule)
7878
$applyOptions = [
7979
['label' => __('Percent of product price discount'), 'value' => Rule::BY_PERCENT_ACTION],
8080
['label' => __('Fixed amount discount'), 'value' => Rule::BY_FIXED_ACTION],
81-
['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::BY_PERCENT_ACTION],
81+
['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::CART_FIXED_ACTION],
8282
['label' => __('Buy X get Y free (discount amount is Y)'), 'value' => Rule::BUY_X_GET_Y_ACTION]
8383
];
8484

0 commit comments

Comments
 (0)