@@ -90,8 +90,8 @@ private function createValidator(): SalesRuleProduct
90
90
->setMethods (['loadAllAttributes ' , 'getConnection ' , 'getTable ' ])
91
91
->getMock ();
92
92
$ productMock ->expects ($ this ->any ())
93
- ->method ('loadAllAttributes ' )
94
- ->willReturn ($ attributeLoaderInterfaceMock );
93
+ ->method ('loadAllAttributes ' )
94
+ ->willReturn ($ attributeLoaderInterfaceMock );
95
95
/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
96
96
$ collectionMock = $ this ->getMockBuilder (Collection::class)
97
97
->disableOriginalConstructor ()
@@ -195,4 +195,35 @@ private function createProductMock(): \PHPUnit_Framework_MockObject_MockObject
195
195
196
196
return $ productMock ;
197
197
}
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
+ }
198
229
}
0 commit comments