@@ -11,7 +11,7 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
11
11
{
12
12
protected $ worker ;
13
13
14
- public function setUp ()
14
+ public function setUp (): void
15
15
{
16
16
parent ::setUp ();
17
17
@@ -26,13 +26,12 @@ public function testJobCanBeQueued()
26
26
$ this ->assertTrue ((bool )Resque::enqueue ('jobs ' , 'Test_Job ' ));
27
27
}
28
28
29
- /**
30
- * @expectedException Resque_RedisException
31
- */
32
29
public function testRedisErrorThrowsExceptionOnJobCreation ()
33
30
{
31
+ $ this ->expectException (Resque_RedisException::class);
32
+
34
33
$ mockCredis = $ this ->getMockBuilder ('Credis_Client ' )
35
- ->setMethods (['connect ' , '__call ' ])
34
+ ->onlyMethods (['connect ' , '__call ' ])
36
35
->getMock ();
37
36
$ mockCredis ->expects ($ this ->any ())->method ('__call ' )
38
37
->will ($ this ->throwException (new CredisException ('failure ' )));
@@ -55,11 +54,10 @@ public function testQeueuedJobCanBeReserved()
55
54
$ this ->assertEquals ('Test_Job ' , $ job ->payload ['class ' ]);
56
55
}
57
56
58
- /**
59
- * @expectedException InvalidArgumentException
60
- */
61
57
public function testObjectArgumentsCannotBePassedToJob ()
62
58
{
59
+ $ this ->expectException (InvalidArgumentException::class);
60
+
63
61
$ args = new stdClass ;
64
62
$ args ->test = 'somevalue ' ;
65
63
Resque::enqueue ('jobs ' , 'Test_Job ' , $ args );
@@ -132,22 +130,20 @@ public function testFailedJobExceptionsAreCaught()
132
130
$ this ->assertEquals (1 , Resque_Stat::get ('failed: ' .$ this ->worker ));
133
131
}
134
132
135
- /**
136
- * @expectedException Resque_Exception
137
- */
138
133
public function testJobWithoutPerformMethodThrowsException ()
139
134
{
135
+ $ this ->expectException (Resque_Exception::class);
136
+
140
137
Resque::enqueue ('jobs ' , 'Test_Job_Without_Perform_Method ' );
141
138
$ job = $ this ->worker ->reserve ();
142
139
$ job ->worker = $ this ->worker ;
143
140
$ job ->perform ();
144
141
}
145
142
146
- /**
147
- * @expectedException Resque_Exception
148
- */
149
143
public function testInvalidJobThrowsException ()
150
144
{
145
+ $ this ->expectException (Resque_Exception::class);
146
+
151
147
Resque::enqueue ('jobs ' , 'Invalid_Job ' );
152
148
$ job = $ this ->worker ->reserve ();
153
149
$ job ->worker = $ this ->worker ;
@@ -311,7 +307,7 @@ public function testDequeueWrongItemID2()
311
307
{
312
308
$ queue = 'jobs ' ;
313
309
Resque::enqueue ($ queue , 'Test_Job_Dequeue ' );
314
- $ qid = Resque::enqueue ($ queue , 'Test_Job_Dequeue ' );
310
+ Resque::enqueue ($ queue , 'Test_Job_Dequeue ' );
315
311
$ this ->assertEquals (Resque::size ($ queue ), 2 );
316
312
$ test = array ('Test_Job_Dequeue ' => 'r4nD0mH4sh3dId ' );
317
313
$ this ->assertEquals (Resque::dequeue ($ queue , $ test ), 0 );
@@ -349,7 +345,7 @@ public function testDequeueSeveralItemsWithArgs()
349
345
$ this ->assertEquals ($ removedItems , 2 );
350
346
$ this ->assertEquals (Resque::size ($ queue ), 1 );
351
347
$ item = Resque::pop ($ queue );
352
- $ this ->assertInternalType ( ' array ' , $ item ['args ' ]);
348
+ $ this ->assertIsArray ( $ item ['args ' ]);
353
349
$ this ->assertEquals (10 , $ item ['args ' ][0 ]['bar ' ], 'Wrong items were dequeued from queue! ' );
354
350
}
355
351
@@ -410,9 +406,12 @@ public function testDoNotUseFactoryToGetInstance()
410
406
'args ' => array (array ())
411
407
);
412
408
$ job = new Resque_Job ('jobs ' , $ payload );
413
- $ factory = $ this ->getMock ('Resque_Job_FactoryInterface ' );
414
- $ testJob = $ this ->getMock ('Resque_JobInterface ' );
415
- $ factory ->expects (self ::never ())->method ('create ' )->will (self ::returnValue ($ testJob ));
409
+ /** @var $factory MockObject|Resque_Job_FactoryInterface */
410
+ $ factory = $ this ->createMock ('Resque_Job_FactoryInterface ' );
411
+ $ testJob = $ this ->createMock ('Resque_JobInterface ' );
412
+ $ factory ->expects (self ::never ())
413
+ ->method ('create ' )
414
+ ->will (self ::returnValue ($ testJob ));
416
415
$ instance = $ job ->getInstance ();
417
416
$ this ->assertInstanceOf ('Resque_JobInterface ' , $ instance );
418
417
}
0 commit comments