Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit c52e0e8

Browse files
committed
Covered case when simple product is being validated
1 parent 90ff989 commit c52e0e8

File tree

1 file changed

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

1 file changed

+33
-2
lines changed

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ private function createValidator(): SalesRuleProduct
9090
->setMethods(['loadAllAttributes', 'getConnection', 'getTable'])
9191
->getMock();
9292
$productMock->expects($this->any())
93-
->method('loadAllAttributes')
94-
->willReturn($attributeLoaderInterfaceMock);
93+
->method('loadAllAttributes')
94+
->willReturn($attributeLoaderInterfaceMock);
9595
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
9696
$collectionMock = $this->getMockBuilder(Collection::class)
9797
->disableOriginalConstructor()
@@ -195,4 +195,35 @@ private function createProductMock(): \PHPUnit_Framework_MockObject_MockObject
195195

196196
return $productMock;
197197
}
198+
199+
public function testChildIsNotUsedForValidation()
200+
{
201+
$simpleProductMock = $this->createProductMock();
202+
$simpleProductMock
203+
->expects($this->any())
204+
->method('getTypeId')
205+
->willReturn(Type::TYPE_SIMPLE);
206+
$simpleProductMock
207+
->expects($this->any())
208+
->method('hasData')
209+
->with($this->equalTo('special_price'))
210+
->willReturn(true);
211+
212+
/* @var AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */
213+
$item = $this->getMockBuilder(AbstractItem::class)
214+
->disableOriginalConstructor()
215+
->setMethods(['setProduct', 'getProduct'])
216+
->getMockForAbstractClass();
217+
$item->expects($this->any())
218+
->method('getProduct')
219+
->willReturn($simpleProductMock);
220+
221+
$item->expects($this->once())
222+
->method('setProduct')
223+
->with($this->identicalTo($simpleProductMock));
224+
225+
$this->validator->setAttribute('special_price');
226+
227+
$this->validatorPlugin->beforeValidate($this->validator, $item);
228+
}
198229
}

0 commit comments

Comments
 (0)