@@ -293,15 +293,19 @@ public function testLazy()
293
293
$ connection = Connection::fromDsn ('redis://localhost/messenger-lazy?lazy=1 ' , [], $ redis );
294
294
295
295
$ connection ->add ('1 ' , []);
296
- $ this ->assertNotEmpty ($ message = $ connection ->get ());
297
- $ this ->assertSame ([
298
- 'message ' => json_encode ([
299
- 'body ' => '1 ' ,
300
- 'headers ' => [],
301
- ]),
302
- ], $ message ['data ' ]);
303
- $ connection ->reject ($ message ['id ' ]);
304
- $ redis ->del ('messenger-lazy ' );
296
+
297
+ try {
298
+ $ this ->assertNotEmpty ($ message = $ connection ->get ());
299
+ $ this ->assertSame ([
300
+ 'message ' => json_encode ([
301
+ 'body ' => '1 ' ,
302
+ 'headers ' => [],
303
+ ]),
304
+ ], $ message ['data ' ]);
305
+ $ connection ->reject ($ message ['id ' ]);
306
+ } finally {
307
+ $ redis ->del ('messenger-lazy ' );
308
+ }
305
309
}
306
310
307
311
public function testDbIndex ()
@@ -328,13 +332,16 @@ public function testFromDsnWithMultipleHosts()
328
332
public function testJsonError ()
329
333
{
330
334
$ redis = $ this ->createRedisClient ();
331
- $ connection = Connection::fromDsn ('redis://localhost/json-error ' , [], $ redis );
335
+ $ connection = Connection::fromDsn ('redis://localhost/messenger- json-error ' , [], $ redis );
332
336
try {
333
337
$ connection ->add ("\xB1\x31" , []);
338
+
339
+ $ this ->fail ('Expected exception to be thrown. ' );
334
340
} catch (TransportException $ e ) {
341
+ $ this ->assertSame ('Malformed UTF-8 characters, possibly incorrectly encoded ' , $ e ->getMessage ());
342
+ } finally {
343
+ $ redis ->del ('messenger-json-error ' );
335
344
}
336
-
337
- $ this ->assertSame ('Malformed UTF-8 characters, possibly incorrectly encoded ' , $ e ->getMessage ());
338
345
}
339
346
340
347
public function testGetNonBlocking ()
@@ -343,29 +350,41 @@ public function testGetNonBlocking()
343
350
344
351
$ connection = Connection::fromDsn ('redis://localhost/messenger-getnonblocking ' , ['sentinel_master ' => null ], $ redis );
345
352
346
- $ this ->assertNull ($ connection ->get ()); // no message, should return null immediately
347
- $ connection ->add ('1 ' , []);
348
- $ this ->assertNotEmpty ($ message = $ connection ->get ());
349
- $ connection ->reject ($ message ['id ' ]);
350
- $ redis ->del ('messenger-getnonblocking ' );
353
+ try {
354
+ $ this ->assertNull ($ connection ->get ()); // no message, should return null immediately
355
+ $ connection ->add ('1 ' , []);
356
+ $ this ->assertNotEmpty ($ message = $ connection ->get ());
357
+ $ connection ->reject ($ message ['id ' ]);
358
+ } finally {
359
+ $ redis ->del ('messenger-getnonblocking ' );
360
+ }
351
361
}
352
362
353
363
public function testGetAfterReject ()
354
364
{
355
365
$ redis = $ this ->createRedisClient ();
356
366
$ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['sentinel_master ' => null ], $ redis );
357
367
358
- $ connection ->add ('1 ' , []);
359
- $ connection ->add ('2 ' , []);
368
+ try {
369
+ $ connection ->add ('1 ' , []);
370
+ $ connection ->add ('2 ' , []);
360
371
361
- $ failing = $ connection ->get ();
362
- $ connection ->reject ($ failing ['id ' ]);
372
+ $ failing = $ connection ->get ();
373
+ $ connection ->reject ($ failing ['id ' ]);
363
374
375
+ <<<<<<< HEAD
364
376
$ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['sentinel_master ' => null ]);
365
377
366
378
$ this ->assertNotNull ($ connection ->get ());
367
379
368
380
$ redis ->del ('messenger-rejectthenget ' );
381
+ =======
382
+ $ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['delete_after_ack ' => true ]);
383
+ $ this ->assertNotNull ($ connection ->get ());
384
+ } finally {
385
+ $ redis ->del ('messenger-rejectthenget ' );
386
+ }
387
+ >>>>>>> 5.4
369
388
}
370
389
371
390
public function testItProperlyHandlesEmptyMessages ()
0 commit comments