Skip to content

Commit 1af95de

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MAGETWO-90539
2 parents 1a08f4e + 498d679 commit 1af95de

File tree

33 files changed

+481
-211
lines changed

33 files changed

+481
-211
lines changed

app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function validateOptionType(Option $option)
132132
*/
133133
protected function validateOptionValue(Option $option)
134134
{
135-
return $this->isInRange($option->getPriceType(), $this->priceTypes) && !$this->isNegative($option->getPrice());
135+
return $this->isInRange($option->getPriceType(), $this->priceTypes);
136136
}
137137

138138
/**

app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function isValidOptionPrice($priceType, $price, $storeId)
8383
if (!$priceType && !$price) {
8484
return true;
8585
}
86-
if (!$this->isInRange($priceType, $this->priceTypes) || $this->isNegative($price)) {
86+
if (!$this->isInRange($priceType, $this->priceTypes)) {
8787
return false;
8888
}
8989

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptions.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
<description value="Admin should be able to sell products with different variants of their own"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-61717"/>
19-
<skip>
20-
<issueId value="MAGETWO-90719"/>
21-
</skip>
19+
<group value="Catalog"/>
2220
</annotations>
2321
<before>
2422
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class DefaultValidatorTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
protected $valueMock;
2020

21+
/**
22+
* @inheritdoc
23+
*/
2124
protected function setUp()
2225
{
2326
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -60,31 +63,30 @@ public function isValidTitleDataProvider()
6063
{
6164
$mess = ['option required fields' => 'Missed values for option required fields'];
6265
return [
63-
['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
64-
['option_title', 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 0]), [], true],
65-
[null, 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
66-
[null, 'name 1.1', 'fixed', 10, new \Magento\Framework\DataObject(['store_id' => 0]), $mess, false],
66+
['option_title', 'name 1.1', 'fixed', new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
67+
['option_title', 'name 1.1', 'fixed', new \Magento\Framework\DataObject(['store_id' => 0]), [], true],
68+
[null, 'name 1.1', 'fixed', new \Magento\Framework\DataObject(['store_id' => 1]), [], true],
69+
[null, 'name 1.1', 'fixed', new \Magento\Framework\DataObject(['store_id' => 0]), $mess, false],
6770
];
6871
}
6972

7073
/**
71-
* @param $title
72-
* @param $type
73-
* @param $priceType
74-
* @param $price
75-
* @param $product
76-
* @param $messages
77-
* @param $result
74+
* @param string $title
75+
* @param string $type
76+
* @param string $priceType
77+
* @param \Magento\Framework\DataObject $product
78+
* @param array $messages
79+
* @param bool $result
7880
* @dataProvider isValidTitleDataProvider
7981
*/
80-
public function testIsValidTitle($title, $type, $priceType, $price, $product, $messages, $result)
82+
public function testIsValidTitle($title, $type, $priceType, $product, $messages, $result)
8183
{
82-
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
84+
$methods = ['getTitle', 'getType', 'getPriceType', '__wakeup', 'getProduct'];
8385
$valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
8486
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title));
8587
$valueMock->expects($this->any())->method('getType')->will($this->returnValue($type));
8688
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType));
87-
$valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price));
89+
// $valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price));
8890
$valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product));
8991
$this->assertEquals($result, $this->validator->isValid($valueMock));
9092
$this->assertEquals($messages, $this->validator->getMessages());
@@ -104,7 +106,7 @@ public function isValidFailDataProvider()
104106
}
105107

106108
/**
107-
* @param $product
109+
* @param \Magento\Framework\DataObject $product
108110
* @dataProvider isValidFailDataProvider
109111
*/
110112
public function testIsValidFail($product)
@@ -124,41 +126,4 @@ public function testIsValidFail($product)
124126
$this->assertFalse($this->validator->isValid($valueMock));
125127
$this->assertEquals($messages, $this->validator->getMessages());
126128
}
127-
128-
/**
129-
* Data provider for testValidationNegativePrice
130-
* @return array
131-
*/
132-
public function validationNegativePriceDataProvider()
133-
{
134-
return [
135-
['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\DataObject(['store_id' => 1])],
136-
['option_title', 'name 1.1', 'fixed', -12, new \Magento\Framework\DataObject(['store_id' => 0])],
137-
];
138-
}
139-
140-
/**
141-
* @param $title
142-
* @param $type
143-
* @param $priceType
144-
* @param $price
145-
* @param $product
146-
* @dataProvider validationNegativePriceDataProvider
147-
*/
148-
public function testValidationNegativePrice($title, $type, $priceType, $price, $product)
149-
{
150-
$methods = ['getTitle', 'getType', 'getPriceType', 'getPrice', '__wakeup', 'getProduct'];
151-
$valueMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, $methods);
152-
$valueMock->expects($this->once())->method('getTitle')->will($this->returnValue($title));
153-
$valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue($type));
154-
$valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue($priceType));
155-
$valueMock->expects($this->once())->method('getPrice')->will($this->returnValue($price));
156-
$valueMock->expects($this->once())->method('getProduct')->will($this->returnValue($product));
157-
158-
$messages = [
159-
'option values' => 'Invalid option value',
160-
];
161-
$this->assertFalse($this->validator->isValid($valueMock));
162-
$this->assertEquals($messages, $this->validator->getMessages());
163-
}
164129
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class FileTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
protected $valueMock;
2020

21+
/**
22+
* @inheritdoc
23+
*/
2124
protected function setUp()
2225
{
2326
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -54,24 +57,34 @@ protected function setUp()
5457
);
5558
}
5659

60+
/**
61+
* @return void
62+
*/
5763
public function testIsValidSuccess()
5864
{
5965
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
6066
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
61-
$this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
62-
$this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10));
67+
$this->valueMock->method('getPriceType')
68+
->willReturn('fixed');
69+
$this->valueMock->method('getPrice')
70+
->willReturn(10);
6371
$this->valueMock->expects($this->once())->method('getImageSizeX')->will($this->returnValue(10));
6472
$this->valueMock->expects($this->once())->method('getImageSizeY')->will($this->returnValue(15));
6573
$this->assertEmpty($this->validator->getMessages());
6674
$this->assertTrue($this->validator->isValid($this->valueMock));
6775
}
6876

77+
/**
78+
* @return void
79+
*/
6980
public function testIsValidWithNegativeImageSize()
7081
{
7182
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
7283
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
73-
$this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
74-
$this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10));
84+
$this->valueMock->method('getPriceType')
85+
->willReturn('fixed');
86+
$this->valueMock->method('getPrice')
87+
->willReturn(10);
7588
$this->valueMock->expects($this->once())->method('getImageSizeX')->will($this->returnValue(-10));
7689
$this->valueMock->expects($this->never())->method('getImageSizeY');
7790
$messages = [
@@ -81,12 +94,17 @@ public function testIsValidWithNegativeImageSize()
8194
$this->assertEquals($messages, $this->validator->getMessages());
8295
}
8396

97+
/**
98+
* @return void
99+
*/
84100
public function testIsValidWithNegativeImageSizeY()
85101
{
86102
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
87103
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
88-
$this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
89-
$this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10));
104+
$this->valueMock->method('getPriceType')
105+
->willReturn('fixed');
106+
$this->valueMock->method('getPrice')
107+
->willReturn(10);
90108
$this->valueMock->expects($this->once())->method('getImageSizeX')->will($this->returnValue(10));
91109
$this->valueMock->expects($this->once())->method('getImageSizeY')->will($this->returnValue(-10));
92110
$messages = [

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class SelectTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
protected $valueMock;
2020

21+
/**
22+
* @inheritdoc
23+
*/
2124
protected function setUp()
2225
{
2326
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -90,7 +93,7 @@ public function isValidSuccessDataProvider()
9093
]
9194
],
9295
[
93-
false,
96+
true,
9497
[
9598
'title' => 'Some Title',
9699
'price_type' => 'fixed',
@@ -100,6 +103,9 @@ public function isValidSuccessDataProvider()
100103
];
101104
}
102105

106+
/**
107+
* @return void
108+
*/
103109
public function testIsValidateWithInvalidOptionValues()
104110
{
105111
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -118,6 +124,9 @@ public function testIsValidateWithInvalidOptionValues()
118124
$this->assertEquals($messages, $this->validator->getMessages());
119125
}
120126

127+
/**
128+
* @return void
129+
*/
121130
public function testIsValidateWithEmptyValues()
122131
{
123132
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -163,7 +172,6 @@ public function testIsValidateWithInvalidData($priceType, $price, $title)
163172
public function isValidateWithInvalidDataDataProvider()
164173
{
165174
return [
166-
'invalid_price' => ['fixed', -10, 'Title'],
167175
'invalid_price_type' => ['some_value', '10', 'Title'],
168176
'empty_title' => ['fixed', 10, null]
169177
];

app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class TextTest extends \PHPUnit\Framework\TestCase
1818
*/
1919
protected $valueMock;
2020

21+
/**
22+
* @inheritdoc
23+
*/
2124
protected function setUp()
2225
{
2326
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -54,23 +57,33 @@ protected function setUp()
5457
);
5558
}
5659

60+
/**
61+
* @return void
62+
*/
5763
public function testIsValidSuccess()
5864
{
5965
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
6066
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
61-
$this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
62-
$this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10));
67+
$this->valueMock->method('getPriceType')
68+
->willReturn('fixed');
69+
$this->valueMock->method('getPrice')
70+
->willReturn(10);
6371
$this->valueMock->expects($this->once())->method('getMaxCharacters')->will($this->returnValue(10));
6472
$this->assertTrue($this->validator->isValid($this->valueMock));
6573
$this->assertEmpty($this->validator->getMessages());
6674
}
6775

76+
/**
77+
* @return void
78+
*/
6879
public function testIsValidWithNegativeMaxCharacters()
6980
{
7081
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
7182
$this->valueMock->expects($this->exactly(2))->method('getType')->will($this->returnValue('name 1.1'));
72-
$this->valueMock->expects($this->once())->method('getPriceType')->will($this->returnValue('fixed'));
73-
$this->valueMock->expects($this->once())->method('getPrice')->will($this->returnValue(10));
83+
$this->valueMock->method('getPriceType')
84+
->willReturn('fixed');
85+
$this->valueMock->method('getPrice')
86+
->willReturn(10);
7487
$this->valueMock->expects($this->once())->method('getMaxCharacters')->will($this->returnValue(-10));
7588
$messages = [
7689
'option values' => 'Invalid option value',

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function __construct(
166166
}
167167

168168
/**
169-
* {@inheritdoc}
169+
* @inheritdoc
170170
* @since 101.0.0
171171
*/
172172
public function modifyData(array $data)
@@ -226,7 +226,7 @@ protected function formatPriceByPath($path, array $data)
226226
}
227227

228228
/**
229-
* {@inheritdoc}
229+
* @inheritdoc
230230
* @since 101.0.0
231231
*/
232232
public function modifyMeta(array $meta)
@@ -923,7 +923,7 @@ protected function getPriceFieldConfig($sortOrder)
923923
'addbeforePool' => $this->productOptionsPrice->prefixesToOptionArray(),
924924
'sortOrder' => $sortOrder,
925925
'validation' => [
926-
'validate-zero-or-greater' => true
926+
'validate-number' => true
927927
],
928928
],
929929
],

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,23 @@ define([
6161
};
6262
events['click ' + this.options.button.checkout] = $.proxy(function () {
6363
var cart = customerData.get('cart'),
64-
customer = customerData.get('customer');
64+
customer = customerData.get('customer'),
65+
element = $(this.options.button.checkout);
6566

6667
if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
6768
// set URL for redirect on successful login/registration. It's postprocessed on backend.
6869
$.cookie('login_redirect', this.options.url.checkout);
6970

7071
if (this.options.url.isRedirectRequired) {
72+
element.prop('disabled', true);
7173
location.href = this.options.url.loginUrl;
7274
} else {
7375
authenticationPopup.showModal();
7476
}
7577

7678
return false;
7779
}
80+
element.prop('disabled', true);
7881
location.href = this.options.url.checkout;
7982
}, this);
8083

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
232232
* @param \Magento\Framework\Stdlib\DateTime $dateTime
233233
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
234234
* @param array $data
235-
* @param \Magento\Dhl\Model\Validator\XmlValidatorFactory $xmlValidatorFactory
235+
* @param \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator
236236
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
237237
*/
238238
public function __construct(
@@ -1970,6 +1970,6 @@ protected function isDutiable($origCountryId, $destCountryId)
19701970

19711971
return
19721972
self::DHL_CONTENT_TYPE_NON_DOC == $this->getConfigData('content_type')
1973-
&& !$this->_isDomestic;
1973+
|| !$this->_isDomestic;
19741974
}
19751975
}

0 commit comments

Comments
 (0)