@@ -94,6 +94,38 @@ public function testPushWithPriority()
9494 ]);
9595 }
9696
97+ public function testPushAndPopWithPriority ()
98+ {
99+ $ handler = new DatabaseHandler ($ this ->config );
100+ $ result = $ handler ->push ('queue ' , 'success ' , ['key1 ' => 'value1 ' ]);
101+
102+ $ this ->assertTrue ($ result );
103+ $ this ->seeInDatabase ('queue_jobs ' , [
104+ 'queue ' => 'queue ' ,
105+ 'payload ' => json_encode (['job ' => 'success ' , 'data ' => ['key1 ' => 'value1 ' ]]),
106+ 'priority ' => 'low ' ,
107+ ]);
108+
109+ $ result = $ handler ->setPriority ('high ' )->push ('queue ' , 'success ' , ['key2 ' => 'value2 ' ]);
110+
111+ $ this ->assertTrue ($ result );
112+ $ this ->seeInDatabase ('queue_jobs ' , [
113+ 'queue ' => 'queue ' ,
114+ 'payload ' => json_encode (['job ' => 'success ' , 'data ' => ['key2 ' => 'value2 ' ]]),
115+ 'priority ' => 'high ' ,
116+ ]);
117+
118+ $ result = $ handler ->pop ('queue ' , ['high ' , 'low ' ]);
119+ $ this ->assertInstanceOf (QueueJob::class, $ result );
120+ $ payload = ['job ' => 'success ' , 'data ' => ['key2 ' => 'value2 ' ]];
121+ $ this ->assertSame ($ payload , $ result ->payload );
122+
123+ $ result = $ handler ->pop ('queue ' , ['high ' , 'low ' ]);
124+ $ this ->assertInstanceOf (QueueJob::class, $ result );
125+ $ payload = ['job ' => 'success ' , 'data ' => ['key1 ' => 'value1 ' ]];
126+ $ this ->assertSame ($ payload , $ result ->payload );
127+ }
128+
97129 /**
98130 * @throws ReflectionException
99131 */
@@ -118,6 +150,30 @@ public function testPushWithPriorityException()
118150 $ handler ->setPriority ('invalid ' )->push ('queue ' , 'success ' , ['key ' => 'value ' ]);
119151 }
120152
153+ /**
154+ * @throws ReflectionException
155+ */
156+ public function testPushWithIncorrectQueueFormatException ()
157+ {
158+ $ this ->expectException (QueueException::class);
159+ $ this ->expectExceptionMessage ('The queue name should consists only lowercase letters or numbers. ' );
160+
161+ $ handler = new DatabaseHandler ($ this ->config );
162+ $ handler ->push ('queue* ' , 'success ' , ['key ' => 'value ' ]);
163+ }
164+
165+ /**
166+ * @throws ReflectionException
167+ */
168+ public function testPushWithTooLongQueueNameException ()
169+ {
170+ $ this ->expectException (QueueException::class);
171+ $ this ->expectExceptionMessage ('The queue name is too long. It should be no longer than 64 letters. ' );
172+
173+ $ handler = new DatabaseHandler ($ this ->config );
174+ $ handler ->push (str_repeat ('a ' ,65 ), 'success ' , ['key ' => 'value ' ]);
175+ }
176+
121177 /**
122178 * @throws ReflectionException
123179 */
@@ -284,6 +340,14 @@ public function testForget()
284340 ]);
285341 }
286342
343+ public function testForgetFalse ()
344+ {
345+ $ handler = new DatabaseHandler ($ this ->config );
346+ $ result = $ handler ->forget (1111 );
347+
348+ $ this ->assertFalse ($ result );
349+ }
350+
287351 /**
288352 * @throws ReflectionException
289353 */
0 commit comments