@@ -35,6 +35,51 @@ public function testShouldCreateJobObject()
35
35
->with ('entity-class ' )
36
36
->will ($ this ->returnValue ($ repository ))
37
37
;
38
+ $ em
39
+ ->expects ($ this ->any ())
40
+ ->method ('isOpen ' )
41
+ ->will ($ this ->returnValue (true ))
42
+ ;
43
+
44
+ $ doctrine = $ this ->createDoctrineMock ();
45
+ $ doctrine
46
+ ->expects ($ this ->once ())
47
+ ->method ('getManagerForClass ' )
48
+ ->with ('entity-class ' )
49
+ ->will ($ this ->returnValue ($ em ))
50
+ ;
51
+ $ doctrine
52
+ ->expects ($ this ->never ())
53
+ ->method ('resetManager ' )
54
+ ;
55
+
56
+ $ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
57
+ $ job = $ storage ->createJob ();
58
+
59
+ $ this ->assertInstanceOf (Job::class, $ job );
60
+ }
61
+
62
+ public function testShouldResetManagerAndCreateJobObject ()
63
+ {
64
+ $ repository = $ this ->createRepositoryMock ();
65
+ $ repository
66
+ ->expects ($ this ->once ())
67
+ ->method ('getClassName ' )
68
+ ->will ($ this ->returnValue (Job::class))
69
+ ;
70
+
71
+ $ em = $ this ->createEntityManagerMock ();
72
+ $ em
73
+ ->expects ($ this ->once ())
74
+ ->method ('getRepository ' )
75
+ ->with ('entity-class ' )
76
+ ->will ($ this ->returnValue ($ repository ))
77
+ ;
78
+ $ em
79
+ ->expects ($ this ->any ())
80
+ ->method ('isOpen ' )
81
+ ->will ($ this ->returnValue (false ))
82
+ ;
38
83
39
84
$ doctrine = $ this ->createDoctrineMock ();
40
85
$ doctrine
@@ -43,6 +88,11 @@ public function testShouldCreateJobObject()
43
88
->with ('entity-class ' )
44
89
->will ($ this ->returnValue ($ em ))
45
90
;
91
+ $ doctrine
92
+ ->expects ($ this ->any ())
93
+ ->method ('resetManager ' )
94
+ ->will ($ this ->returnValue ($ em ))
95
+ ;
46
96
47
97
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
48
98
$ job = $ storage ->createJob ();
@@ -66,6 +116,11 @@ public function testShouldThrowIfGotUnexpectedJobInstance()
66
116
->with ('entity-class ' )
67
117
->will ($ this ->returnValue ($ repository ))
68
118
;
119
+ $ em
120
+ ->expects ($ this ->any ())
121
+ ->method ('isOpen ' )
122
+ ->will ($ this ->returnValue (true ))
123
+ ;
69
124
70
125
$ doctrine = $ this ->createDoctrineMock ();
71
126
$ doctrine
@@ -74,6 +129,10 @@ public function testShouldThrowIfGotUnexpectedJobInstance()
74
129
->with ('entity-class ' )
75
130
->will ($ this ->returnValue ($ em ))
76
131
;
132
+ $ doctrine
133
+ ->expects ($ this ->never ())
134
+ ->method ('resetManager ' )
135
+ ;
77
136
78
137
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
79
138
@@ -120,6 +179,11 @@ public function testShouldSaveJobWithoutLockIfThereIsNoCallbackAndChildJob()
120
179
->expects ($ this ->never ())
121
180
->method ('transactional ' )
122
181
;
182
+ $ em
183
+ ->expects ($ this ->any ())
184
+ ->method ('isOpen ' )
185
+ ->will ($ this ->returnValue (true ))
186
+ ;
123
187
124
188
$ doctrine = $ this ->createDoctrineMock ();
125
189
$ doctrine
@@ -128,6 +192,10 @@ public function testShouldSaveJobWithoutLockIfThereIsNoCallbackAndChildJob()
128
192
->with ('entity-class ' )
129
193
->will ($ this ->returnValue ($ em ))
130
194
;
195
+ $ doctrine
196
+ ->expects ($ this ->never ())
197
+ ->method ('resetManager ' )
198
+ ;
131
199
132
200
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
133
201
$ storage ->saveJob ($ child );
@@ -165,6 +233,11 @@ public function testShouldSaveJobWithLockIfWithCallback()
165
233
->expects ($ this ->once ())
166
234
->method ('transactional ' )
167
235
;
236
+ $ em
237
+ ->expects ($ this ->any ())
238
+ ->method ('isOpen ' )
239
+ ->will ($ this ->returnValue (true ))
240
+ ;
168
241
169
242
$ doctrine = $ this ->createDoctrineMock ();
170
243
$ doctrine
@@ -173,6 +246,10 @@ public function testShouldSaveJobWithLockIfWithCallback()
173
246
->with ('entity-class ' )
174
247
->will ($ this ->returnValue ($ em ))
175
248
;
249
+ $ doctrine
250
+ ->expects ($ this ->never ())
251
+ ->method ('resetManager ' )
252
+ ;
176
253
177
254
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
178
255
$ storage ->saveJob ($ job , function () {
@@ -219,6 +296,11 @@ public function testShouldCatchUniqueConstraintViolationExceptionAndThrowDuplica
219
296
->method ('getConnection ' )
220
297
->will ($ this ->returnValue ($ connection ))
221
298
;
299
+ $ em
300
+ ->expects ($ this ->any ())
301
+ ->method ('isOpen ' )
302
+ ->will ($ this ->returnValue (true ))
303
+ ;
222
304
223
305
$ doctrine = $ this ->createDoctrineMock ();
224
306
$ doctrine
@@ -227,6 +309,10 @@ public function testShouldCatchUniqueConstraintViolationExceptionAndThrowDuplica
227
309
->with ('entity-class ' )
228
310
->will ($ this ->returnValue ($ em ))
229
311
;
312
+ $ doctrine
313
+ ->expects ($ this ->never ())
314
+ ->method ('resetManager ' )
315
+ ;
230
316
231
317
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
232
318
@@ -253,6 +339,11 @@ public function testShouldThrowIfTryToSaveNewEntityWithLock()
253
339
->with ('entity-class ' )
254
340
->will ($ this ->returnValue ($ repository ))
255
341
;
342
+ $ em
343
+ ->expects ($ this ->any ())
344
+ ->method ('isOpen ' )
345
+ ->will ($ this ->returnValue (true ))
346
+ ;
256
347
257
348
$ doctrine = $ this ->createDoctrineMock ();
258
349
$ doctrine
@@ -261,6 +352,10 @@ public function testShouldThrowIfTryToSaveNewEntityWithLock()
261
352
->with ('entity-class ' )
262
353
->will ($ this ->returnValue ($ em ))
263
354
;
355
+ $ doctrine
356
+ ->expects ($ this ->never ())
357
+ ->method ('resetManager ' )
358
+ ;
264
359
265
360
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
266
361
@@ -306,6 +401,11 @@ public function testShouldLockEntityAndPassNewInstanceIntoCallback()
306
401
$ callback ($ em );
307
402
}))
308
403
;
404
+ $ em
405
+ ->expects ($ this ->any ())
406
+ ->method ('isOpen ' )
407
+ ->will ($ this ->returnValue (true ))
408
+ ;
309
409
310
410
$ doctrine = $ this ->createDoctrineMock ();
311
411
$ doctrine
@@ -314,6 +414,10 @@ public function testShouldLockEntityAndPassNewInstanceIntoCallback()
314
414
->with ('entity-class ' )
315
415
->will ($ this ->returnValue ($ em ))
316
416
;
417
+ $ doctrine
418
+ ->expects ($ this ->never ())
419
+ ->method ('resetManager ' )
420
+ ;
317
421
318
422
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
319
423
$ resultJob = null ;
@@ -377,6 +481,11 @@ public function testShouldInsertIntoUniqueTableIfJobIsUniqueAndNew()
377
481
->expects ($ this ->once ())
378
482
->method ('flush ' )
379
483
;
484
+ $ em
485
+ ->expects ($ this ->any ())
486
+ ->method ('isOpen ' )
487
+ ->will ($ this ->returnValue (true ))
488
+ ;
380
489
381
490
$ doctrine = $ this ->createDoctrineMock ();
382
491
$ doctrine
@@ -385,6 +494,10 @@ public function testShouldInsertIntoUniqueTableIfJobIsUniqueAndNew()
385
494
->with ('entity-class ' )
386
495
->will ($ this ->returnValue ($ em ))
387
496
;
497
+ $ doctrine
498
+ ->expects ($ this ->never ())
499
+ ->method ('resetManager ' )
500
+ ;
388
501
389
502
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
390
503
$ storage ->saveJob ($ job );
@@ -442,6 +555,11 @@ public function testShouldDeleteRecordFromUniqueTableIfJobIsUniqueAndStoppedAtIs
442
555
->method ('getConnection ' )
443
556
->will ($ this ->returnValue ($ connection ))
444
557
;
558
+ $ em
559
+ ->expects ($ this ->any ())
560
+ ->method ('isOpen ' )
561
+ ->will ($ this ->returnValue (true ))
562
+ ;
445
563
446
564
$ doctrine = $ this ->createDoctrineMock ();
447
565
$ doctrine
@@ -450,6 +568,10 @@ public function testShouldDeleteRecordFromUniqueTableIfJobIsUniqueAndStoppedAtIs
450
568
->with ('entity-class ' )
451
569
->will ($ this ->returnValue ($ em ))
452
570
;
571
+ $ doctrine
572
+ ->expects ($ this ->never ())
573
+ ->method ('resetManager ' )
574
+ ;
453
575
454
576
$ storage = new JobStorage ($ doctrine , 'entity-class ' , 'unique_table ' );
455
577
$ storage ->saveJob ($ job , function () {
0 commit comments