@@ -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