@@ -151,7 +151,7 @@ public function testExecute()
151
151
$ this ->itemStep ->execute ($ stepExecution );
152
152
}
153
153
154
- public function testDispatchReaderInvalidItemException ()
154
+ public function testDispatchReadInvalidItemException ()
155
155
{
156
156
$ stepExecution = $ this ->getMockBuilder ('Oro \\Bundle \\BatchBundle \\Entity \\StepExecution ' )
157
157
->disableOriginalConstructor ()
@@ -166,25 +166,28 @@ public function testDispatchReaderInvalidItemException()
166
166
->with (
167
167
EventInterface::INVALID_ITEM ,
168
168
$ this ->logicalAnd (
169
- $ this ->isInstanceOf ('Oro\Bundle\BatchBundle\Event\InvalidItemEvent ' ),
169
+ $ this ->isInstanceOf ('Oro \\ Bundle \\ BatchBundle \\ Event \ \InvalidItemEvent ' ),
170
170
$ this ->attributeEqualTo ('reason ' , 'The read item is invalid ' ),
171
171
$ this ->attributeEqualTo ('item ' , array ('foo ' => 'bar ' ))
172
172
)
173
173
);
174
174
175
- $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemReaderInterface ' );
175
+ $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemReaderTestHelper ' );
176
176
$ reader ->expects ($ this ->exactly (2 ))
177
177
->method ('read ' )
178
178
->will ($ this ->onConsecutiveCalls (
179
179
$ this ->throwException (new InvalidItemException ('The read item is invalid ' , array ('foo ' => 'bar ' ))),
180
180
$ this ->returnValue (null )
181
181
));
182
+ $ reader ->expects ($ this ->any ())
183
+ ->method ('getName ' )
184
+ ->will ($ this ->returnValue ('stub_reader ' ));
182
185
183
- $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemProcessorInterface ' );
186
+ $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemProcessorTestHelper ' );
184
187
$ processor ->expects ($ this ->never ())
185
188
->method ('process ' );
186
189
187
- $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemWriterInterface ' );
190
+ $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemWriterTestHelper ' );
188
191
$ writer ->expects ($ this ->never ())
189
192
->method ('write ' );
190
193
@@ -195,7 +198,7 @@ public function testDispatchReaderInvalidItemException()
195
198
$ stepExecution ->expects ($ this ->once ())
196
199
->method ('addWarning ' )
197
200
->with (
198
- get_class ( $ reader ) ,
201
+ ' stub_reader ' ,
199
202
'The read item is invalid ' ,
200
203
array ('foo ' => 'bar ' )
201
204
);
@@ -219,30 +222,33 @@ public function testDispatchProcessInvalidItemException()
219
222
->with (
220
223
EventInterface::INVALID_ITEM ,
221
224
$ this ->logicalAnd (
222
- $ this ->isInstanceOf ('Oro\Bundle\BatchBundle\Event\InvalidItemEvent ' ),
225
+ $ this ->isInstanceOf ('Oro \\ Bundle \\ BatchBundle \\ Event \ \InvalidItemEvent ' ),
223
226
$ this ->attributeEqualTo ('reason ' , 'The processed item is invalid ' ),
224
227
$ this ->attributeEqualTo ('item ' , array ('foo ' => 'bar ' ))
225
228
)
226
229
);
227
230
228
- $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemReaderInterface ' );
231
+ $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemReaderTestHelper ' );
229
232
$ reader ->expects ($ this ->exactly (2 ))
230
233
->method ('read ' )
231
234
->will ($ this ->onConsecutiveCalls (
232
235
$ this ->returnValue (array ('foo ' => 'bar ' )),
233
236
$ this ->returnValue (null )
234
237
));
235
238
236
- $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemProcessorInterface ' );
239
+ $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemProcessorTestHelper ' );
237
240
$ processor ->expects ($ this ->exactly (1 ))
238
241
->method ('process ' )
239
242
->will (
240
243
$ this ->throwException (
241
244
new InvalidItemException ('The processed item is invalid ' , array ('foo ' => 'bar ' ))
242
245
)
243
246
);
247
+ $ processor ->expects ($ this ->any ())
248
+ ->method ('getName ' )
249
+ ->will ($ this ->returnValue ('stub_processor ' ));
244
250
245
- $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemWriterInterface ' );
251
+ $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemWriterTestHelper ' );
246
252
$ writer ->expects ($ this ->never ())
247
253
->method ('write ' );
248
254
@@ -253,7 +259,7 @@ public function testDispatchProcessInvalidItemException()
253
259
$ stepExecution ->expects ($ this ->once ())
254
260
->method ('addWarning ' )
255
261
->with (
256
- get_class ( $ processor ) ,
262
+ ' stub_processor ' ,
257
263
'The processed item is invalid ' ,
258
264
array ('foo ' => 'bar ' )
259
265
);
@@ -277,35 +283,38 @@ public function testDispatchWriteInvalidItemException()
277
283
->with (
278
284
EventInterface::INVALID_ITEM ,
279
285
$ this ->logicalAnd (
280
- $ this ->isInstanceOf ('Oro\Bundle\BatchBundle\Event\InvalidItemEvent ' ),
286
+ $ this ->isInstanceOf ('Oro \\ Bundle \\ BatchBundle \\ Event \ \InvalidItemEvent ' ),
281
287
$ this ->attributeEqualTo ('reason ' , 'The written item is invalid ' ),
282
288
$ this ->attributeEqualTo ('item ' , array ('foo ' => 'bar ' ))
283
289
)
284
290
);
285
291
286
- $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemReaderInterface ' );
292
+ $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemReaderInterface ' );
287
293
$ reader ->expects ($ this ->exactly (2 ))
288
294
->method ('read ' )
289
295
->will ($ this ->onConsecutiveCalls (
290
296
$ this ->returnValue (array ('foo ' => 'bar ' )),
291
297
$ this ->returnValue (null )
292
298
));
293
299
294
- $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemProcessorInterface ' );
300
+ $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemProcessorTestHelper ' );
295
301
$ processor ->expects ($ this ->exactly (1 ))
296
302
->method ('process ' )
297
303
->will (
298
304
$ this ->returnValue (array ('foo ' => 'bar ' ))
299
305
);
300
306
301
- $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemWriterInterface ' );
307
+ $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemWriterTestHelper ' );
302
308
$ writer ->expects ($ this ->exactly (1 ))
303
309
->method ('write ' )
304
310
->will (
305
311
$ this ->throwException (
306
312
new InvalidItemException ('The written item is invalid ' , array ('foo ' => 'bar ' ))
307
313
)
308
314
);
315
+ $ writer ->expects ($ this ->any ())
316
+ ->method ('getName ' )
317
+ ->will ($ this ->returnValue ('stub_writer ' ));
309
318
310
319
$ this ->itemStep ->setReader ($ reader );
311
320
$ this ->itemStep ->setProcessor ($ processor );
@@ -314,7 +323,7 @@ public function testDispatchWriteInvalidItemException()
314
323
$ stepExecution ->expects ($ this ->once ())
315
324
->method ('addWarning ' )
316
325
->with (
317
- get_class ( $ writer ) ,
326
+ ' stub_writer ' ,
318
327
'The written item is invalid ' ,
319
328
array ('foo ' => 'bar ' )
320
329
);
@@ -335,7 +344,6 @@ public function testProcessShouldNotReturnNull()
335
344
$ stepExecution ->expects ($ this ->once ())
336
345
->method ('addFailureException ' );
337
346
338
-
339
347
$ this ->eventDispatcher
340
348
->expects ($ this ->at (1 ))
341
349
->method ('dispatch ' )
@@ -344,18 +352,17 @@ public function testProcessShouldNotReturnNull()
344
352
$ this ->anything ()
345
353
);
346
354
347
-
348
- $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemReaderInterface ' );
355
+ $ reader = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\Unit \\Item \\ItemReaderTestHelper ' );
349
356
$ reader ->expects ($ this ->any ())
350
357
->method ('read ' )
351
358
->will ($ this ->returnValue (array ('foo ' => 'bar ' )));
352
359
353
- $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemProcessorInterface ' );
360
+ $ processor = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemProcessorTestHelper ' );
354
361
$ processor ->expects ($ this ->any ())
355
362
->method ('process ' )
356
363
->will ($ this ->returnValue (null ));
357
364
358
- $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Item \\ItemWriterInterface ' );
365
+ $ writer = $ this ->getMock ('Oro \\Bundle \\BatchBundle \\Tests \\ Unit \\ Item \\ItemWriterTestHelper ' );
359
366
360
367
$ this ->itemStep ->setReader ($ reader );
361
368
$ this ->itemStep ->setProcessor ($ processor );
@@ -371,12 +378,13 @@ public function testProcessShouldNotReturnNull()
371
378
*/
372
379
protected function assertEntity ($ entity )
373
380
{
374
- $ this ->assertInstanceOf ('Oro\Bundle\BatchBundle\Step\ItemStep ' , $ entity );
381
+ $ this ->assertInstanceOf ('Oro \\ Bundle \\ BatchBundle \\ Step \ \ItemStep ' , $ entity );
375
382
}
383
+
376
384
private function getReaderMock (array $ configuration , array $ fields = array ())
377
385
{
378
386
$ reader = $ this
379
- ->getMockBuilder ('Oro\Bundle\BatchBundle\Tests\Unit\Item\ItemReaderTestHelper ' )
387
+ ->getMockBuilder ('Oro \\ Bundle \\ BatchBundle \\ Tests \\ Unit \\ Item \ \ItemReaderTestHelper ' )
380
388
->disableOriginalConstructor ()
381
389
->getMock ();
382
390
@@ -394,7 +402,7 @@ private function getReaderMock(array $configuration, array $fields = array())
394
402
private function getProcessorMock (array $ configuration , array $ fields = array ())
395
403
{
396
404
$ processor = $ this
397
- ->getMockBuilder ('Oro\Bundle\BatchBundle\Tests\Unit\Item\ItemProcessorTestHelper ' )
405
+ ->getMockBuilder ('Oro \\ Bundle \\ BatchBundle \\ Tests \\ Unit \\ Item \ \ItemProcessorTestHelper ' )
398
406
->disableOriginalConstructor ()
399
407
->getMock ();
400
408
@@ -412,7 +420,7 @@ private function getProcessorMock(array $configuration, array $fields = array())
412
420
private function getWriterMock (array $ configuration , array $ fields = array ())
413
421
{
414
422
$ writer = $ this
415
- ->getMockBuilder ('Oro\Bundle\BatchBundle\Tests\Unit\Item\ItemWriterTestHelper ' )
423
+ ->getMockBuilder ('Oro \\ Bundle \\ BatchBundle \\ Tests \\ Unit \\ Item \ \ItemWriterTestHelper ' )
416
424
->disableOriginalConstructor ()
417
425
->getMock ();
418
426
0 commit comments