File tree 1 file changed +36
-0
lines changed
test/Resque/Tests/Reserver
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,42 @@ public function testWaitAfterReservationAttemptReturnsTrue()
22
22
$ this ->assertFalse ($ this ->getReserver ()->waitAfterReservationAttempt ());
23
23
}
24
24
25
+ public function testReserverWhenNoJobsEnqueuedReturnsNull ()
26
+ {
27
+ $ queues = array (
28
+ 'queue_1 ' ,
29
+ 'queue_2 ' ,
30
+ 'queue_3 ' ,
31
+ );
32
+
33
+ $ redisQueues = array (
34
+ 'queue:queue_1 ' ,
35
+ 'queue:queue_2 ' ,
36
+ 'queue:queue_3 ' ,
37
+ );
38
+
39
+ // hhvm doesn't respect the timeout arg for blpop, so we need to mock this command
40
+ // https://github.com/facebook/hhvm/issues/6286
41
+ $ redis = $ this ->getMockBuilder ('\Resque_Redis ' )
42
+ ->disableOriginalConstructor ()
43
+ ->setMethods (['__call ' ])
44
+ ->getMock ();
45
+
46
+ $ redis
47
+ ->expects ($ this ->once ())
48
+ ->method ('__call ' )
49
+ ->with ($ this ->equalTo ('blpop ' ), $ this ->equalTo (array ($ redisQueues , 1 )))
50
+ ->will ($ this ->returnValue (null ));
51
+
52
+ $ originalRedis = Resque::$ redis ;
53
+
54
+ Resque::$ redis = $ redis ;
55
+
56
+ $ this ->assertNull ($ this ->getReserver ($ queues )->reserve ());
57
+
58
+ Resque::$ redis = $ originalRedis ;
59
+ }
60
+
25
61
public function testReserveCallsBlpopWithTimeout ()
26
62
{
27
63
$ timeout = rand (1 , 100 );
You can’t perform that action at this time.
0 commit comments