Skip to content

Commit 4a287d5

Browse files
committed
MC-22813: Changing Quantity and Adding to cart throws exception
- Add test for guard
1 parent 8d38f69 commit 4a287d5

File tree

1 file changed

+34
-0
lines changed
  • app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/SalesRule/Model/Rule/Condition

1 file changed

+34
-0
lines changed

app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/SalesRule/Model/Rule/Condition/ProductTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,38 @@ public function testChildIsNotUsedForValidation()
223223

224224
$this->validatorPlugin->beforeValidate($this->validator, $item);
225225
}
226+
227+
/**
228+
* Test for Configurable product in invalid state with no children does not raise error
229+
*/
230+
public function testChildIsNotUsedForValidationWhenConfigurableProductIsMissingChildren()
231+
{
232+
$configurableProductMock = $this->createProductMock();
233+
$configurableProductMock
234+
->expects($this->any())
235+
->method('getTypeId')
236+
->willReturn(Configurable::TYPE_CODE);
237+
238+
$configurableProductMock
239+
->expects($this->any())
240+
->method('hasData')
241+
->with($this->equalTo('special_price'))
242+
->willReturn(false);
243+
244+
/* @var AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */
245+
$item = $this->getMockBuilder(AbstractItem::class)
246+
->disableOriginalConstructor()
247+
->setMethods(['setProduct', 'getProduct', 'getChildren'])
248+
->getMockForAbstractClass();
249+
$item->expects($this->any())
250+
->method('getProduct')
251+
->willReturn($configurableProductMock);
252+
$item->expects($this->any())
253+
->method('getChildren')
254+
->willReturn([]);
255+
256+
$this->validator->setAttribute('special_price');
257+
258+
$this->validatorPlugin->beforeValidate($this->validator, $item);
259+
}
226260
}

0 commit comments

Comments
 (0)