Skip to content

Commit df7ecf7

Browse files
MAGETWO-73774: [2.3] Custom option price field disallows negative values #7333
1 parent 0c50659 commit df7ecf7

File tree

7 files changed

+101
-9
lines changed

7 files changed

+101
-9
lines changed

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

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

21+
/**
22+
* Class dependencies initialization
23+
*
24+
* @return void
25+
*/
2126
protected function setUp()
2227
{
2328
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -68,12 +73,12 @@ public function isValidTitleDataProvider()
6873
}
6974

7075
/**
71-
* @param $title
72-
* @param $type
73-
* @param $priceType
74-
* @param $product
75-
* @param $messages
76-
* @param $result
76+
* @param string $title
77+
* @param string $type
78+
* @param string $priceType
79+
* @param \Magento\Framework\DataObject $product
80+
* @param array $messages
81+
* @param bool $result
7782
* @dataProvider isValidTitleDataProvider
7883
*/
7984
public function testIsValidTitle($title, $type, $priceType, $product, $messages, $result)
@@ -103,7 +108,7 @@ public function isValidFailDataProvider()
103108
}
104109

105110
/**
106-
* @param $product
111+
* @param \Magento\Framework\DataObject $product
107112
* @dataProvider isValidFailDataProvider
108113
*/
109114
public function testIsValidFail($product)

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

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

21+
/**
22+
* Class dependencies initialization
23+
*
24+
* @return void
25+
*/
2126
protected function setUp()
2227
{
2328
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -54,6 +59,10 @@ protected function setUp()
5459
);
5560
}
5661

62+
/**
63+
* @throws \Zend_Validate_Exception
64+
* @return void
65+
*/
5766
public function testIsValidSuccess()
5867
{
5968
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -68,6 +77,10 @@ public function testIsValidSuccess()
6877
$this->assertTrue($this->validator->isValid($this->valueMock));
6978
}
7079

80+
/**
81+
* @throws \Zend_Validate_Exception
82+
* @return void
83+
*/
7184
public function testIsValidWithNegativeImageSize()
7285
{
7386
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -85,6 +98,10 @@ public function testIsValidWithNegativeImageSize()
8598
$this->assertEquals($messages, $this->validator->getMessages());
8699
}
87100

101+
/**
102+
* @throws \Zend_Validate_Exception
103+
* @return void
104+
*/
88105
public function testIsValidWithNegativeImageSizeY()
89106
{
90107
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));

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

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

21+
/**
22+
* Class dependencies initialization
23+
*
24+
* @return void
25+
*/
2126
protected function setUp()
2227
{
2328
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -100,6 +105,10 @@ public function isValidSuccessDataProvider()
100105
];
101106
}
102107

108+
/**
109+
* @throws \Zend_Validate_Exception
110+
* @return void
111+
*/
103112
public function testIsValidateWithInvalidOptionValues()
104113
{
105114
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -118,6 +127,10 @@ public function testIsValidateWithInvalidOptionValues()
118127
$this->assertEquals($messages, $this->validator->getMessages());
119128
}
120129

130+
/**
131+
* @throws \Zend_Validate_Exception
132+
* @return void
133+
*/
121134
public function testIsValidateWithEmptyValues()
122135
{
123136
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));

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

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

21+
/**
22+
* Class dependencies initialization
23+
*
24+
* @return void
25+
*/
2126
protected function setUp()
2227
{
2328
$configMock = $this->createMock(\Magento\Catalog\Model\ProductOptions\ConfigInterface::class);
@@ -54,6 +59,10 @@ protected function setUp()
5459
);
5560
}
5661

62+
/**
63+
* @throws \Zend_Validate_Exception
64+
* @return void
65+
*/
5766
public function testIsValidSuccess()
5867
{
5968
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));
@@ -67,6 +76,10 @@ public function testIsValidSuccess()
6776
$this->assertEmpty($this->validator->getMessages());
6877
}
6978

79+
/**
80+
* @throws \Zend_Validate_Exception
81+
* @return void
82+
*/
7083
public function testIsValidWithNegativeMaxCharacters()
7184
{
7285
$this->valueMock->expects($this->once())->method('getTitle')->will($this->returnValue('option_title'));

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

Lines changed: 2 additions & 2 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)

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductPriceTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,30 @@ class ProductPriceTest extends \PHPUnit\Framework\TestCase
2929
*/
3030
private $productRepository;
3131

32+
/**
33+
* Class dependencies initialization
34+
*
35+
* @return void
36+
*/
3237
protected function setUp()
3338
{
3439
$this->_model = Bootstrap::getObjectManager()->create(Product::class);
3540
$this->productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
3641
}
3742

43+
/**
44+
* @return void
45+
*/
3846
public function testGetPrice()
3947
{
4048
$this->assertEmpty($this->_model->getPrice());
4149
$this->_model->setPrice(10.0);
4250
$this->assertEquals(10.0, $this->_model->getPrice());
4351
}
4452

53+
/**
54+
* @return void
55+
*/
4556
public function testGetPriceModel()
4657
{
4758
$default = $this->_model->getPriceModel();
@@ -73,6 +84,9 @@ public function testGetFormatedPrice()
7384
$this->assertEquals('<span class="price">$0.00</span>', $this->_model->getFormatedPrice());
7485
}
7586

87+
/**
88+
* @return void
89+
*/
7690
public function testSetGetFinalPrice()
7791
{
7892
$this->assertEquals(0, $this->_model->getFinalPrice());

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase
3535
*/
3636
protected $_model;
3737

38+
/**
39+
* Class dependencies initialization
40+
*
41+
* @return void
42+
*/
3843
protected function setUp()
3944
{
4045
$this->productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
@@ -45,6 +50,10 @@ protected function setUp()
4550
);
4651
}
4752

53+
/**
54+
* @throws \Magento\Framework\Exception\FileSystemException
55+
* @return void
56+
*/
4857
public static function tearDownAfterClass()
4958
{
5059
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -66,6 +75,9 @@ public static function tearDownAfterClass()
6675
}
6776
}
6877

78+
/**
79+
* @return void
80+
*/
6981
public function testCanAffectOptions()
7082
{
7183
$this->assertFalse($this->_model->canAffectOptions());
@@ -105,6 +117,9 @@ public function testCRUD()
105117
$crud->testCrud();
106118
}
107119

120+
/**
121+
* @return void
122+
*/
108123
public function testCleanCache()
109124
{
110125
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
@@ -125,6 +140,9 @@ public function testCleanCache()
125140
);
126141
}
127142

143+
/**
144+
* @return void
145+
*/
128146
public function testAddImageToMediaGallery()
129147
{
130148
// Model accepts only files in tmp media path, we need to copy fixture file there
@@ -332,13 +350,19 @@ public function testIsVirtual()
332350
$this->assertTrue($model->getIsVirtual());
333351
}
334352

353+
/**
354+
* @return void
355+
*/
335356
public function testToArray()
336357
{
337358
$this->assertEquals([], $this->_model->toArray());
338359
$this->_model->setSku('sku')->setName('name');
339360
$this->assertEquals(['sku' => 'sku', 'name' => 'name'], $this->_model->toArray());
340361
}
341362

363+
/**
364+
* @return void
365+
*/
342366
public function testFromArray()
343367
{
344368
$this->_model->fromArray(['sku' => 'sku', 'name' => 'name', 'stock_item' => ['key' => 'value']]);
@@ -410,6 +434,9 @@ public function testIsProductsHasSku()
410434
);
411435
}
412436

437+
/**
438+
* @return void
439+
*/
413440
public function testProcessBuyRequest()
414441
{
415442
$request = new \Magento\Framework\DataObject();
@@ -418,6 +445,9 @@ public function testProcessBuyRequest()
418445
$this->assertArrayHasKey('errors', $result->getData());
419446
}
420447

448+
/**
449+
* @return void
450+
*/
421451
public function testValidate()
422452
{
423453
$this->_model->setTypeId(

0 commit comments

Comments
 (0)