@@ -96,7 +96,7 @@ public function testShouldBindDefaultQueueOnly()
96
96
$ driver
97
97
->expects ($ this ->once ())
98
98
->method ('createQueue ' )
99
- ->with ('default ' )
99
+ ->with ('default ' , true )
100
100
->willReturn ($ queue )
101
101
;
102
102
@@ -153,7 +153,7 @@ public function testShouldUseRequestedClient()
153
153
$ fooDriver
154
154
->expects ($ this ->once ())
155
155
->method ('createQueue ' )
156
- ->with ('default ' )
156
+ ->with ('default ' , true )
157
157
->willReturn ($ queue )
158
158
;
159
159
@@ -235,7 +235,7 @@ public function testShouldBindDefaultQueueIfRouteUseDifferentQueue()
235
235
$ driver
236
236
->expects ($ this ->once ())
237
237
->method ('createQueue ' )
238
- ->with ('default ' )
238
+ ->with ('default ' , true )
239
239
->willReturn ($ queue )
240
240
;
241
241
@@ -264,13 +264,13 @@ public function testShouldBindCustomExecuteConsumptionAndUseCustomClientDestinat
264
264
$ driver
265
265
->expects ($ this ->at (3 ))
266
266
->method ('createQueue ' )
267
- ->with ('default ' )
267
+ ->with ('default ' , true )
268
268
->willReturn ($ defaultQueue )
269
269
;
270
270
$ driver
271
271
->expects ($ this ->at (4 ))
272
272
->method ('createQueue ' )
273
- ->with ('custom ' )
273
+ ->with ('custom ' , true )
274
274
->willReturn ($ customQueue )
275
275
;
276
276
@@ -307,6 +307,7 @@ public function testShouldBindUserProvidedQueues()
307
307
308
308
$ routeCollection = new RouteCollection ([
309
309
new Route ('topic ' , Route::TOPIC , 'processor ' , ['queue ' => 'custom ' ]),
310
+ new Route ('topic ' , Route::TOPIC , 'processor ' , ['queue ' => 'non-default-queue ' ]),
310
311
]);
311
312
312
313
$ processor = $ this ->createDelegateProcessorMock ();
@@ -315,7 +316,7 @@ public function testShouldBindUserProvidedQueues()
315
316
$ driver
316
317
->expects ($ this ->once ())
317
318
->method ('createQueue ' )
318
- ->with ('non-default-queue ' )
319
+ ->with ('non-default-queue ' , true )
319
320
->willReturn ($ queue )
320
321
;
321
322
@@ -343,6 +344,48 @@ public function testShouldBindUserProvidedQueues()
343
344
]);
344
345
}
345
346
347
+ public function testShouldBindNotPrefixedQueue ()
348
+ {
349
+ $ queue = new NullQueue ('' );
350
+
351
+ $ routeCollection = new RouteCollection ([
352
+ new Route ('topic ' , Route::TOPIC , 'processor ' , ['queue ' => 'non-prefixed-queue ' , 'prefix_queue ' => false ]),
353
+ ]);
354
+
355
+ $ processor = $ this ->createDelegateProcessorMock ();
356
+
357
+ $ driver = $ this ->createDriverStub ($ routeCollection );
358
+ $ driver
359
+ ->expects ($ this ->once ())
360
+ ->method ('createQueue ' )
361
+ ->with ('non-prefixed-queue ' , false )
362
+ ->willReturn ($ queue )
363
+ ;
364
+
365
+ $ consumer = $ this ->createQueueConsumerMock ();
366
+ $ consumer
367
+ ->expects ($ this ->once ())
368
+ ->method ('bind ' )
369
+ ->with ($ this ->identicalTo ($ queue ), $ this ->identicalTo ($ processor ))
370
+ ;
371
+ $ consumer
372
+ ->expects ($ this ->once ())
373
+ ->method ('consume ' )
374
+ ->with ($ this ->isInstanceOf (ChainExtension::class))
375
+ ;
376
+
377
+ $ command = new ConsumeCommand (new Container ([
378
+ 'enqueue.client.default.queue_consumer ' => $ consumer ,
379
+ 'enqueue.client.default.driver ' => $ driver ,
380
+ 'enqueue.client.default.delegate_processor ' => $ processor ,
381
+ ]));
382
+
383
+ $ tester = new CommandTester ($ command );
384
+ $ tester ->execute ([
385
+ 'client-queue-names ' => ['non-prefixed-queue ' ],
386
+ ]);
387
+ }
388
+
346
389
public function testShouldBindQueuesOnlyOnce ()
347
390
{
348
391
$ defaultQueue = new NullQueue ('' );
@@ -360,12 +403,12 @@ public function testShouldBindQueuesOnlyOnce()
360
403
$ driver
361
404
->expects ($ this ->at (3 ))
362
405
->method ('createQueue ' )
363
- ->with ('default ' )
406
+ ->with ('default ' , true )
364
407
->willReturn ($ defaultQueue )
365
408
;
366
409
$ driver
367
410
->expects ($ this ->at (4 ))
368
- ->method ('createQueue ' )
411
+ ->method ('createQueue ' , true )
369
412
->with ('custom ' )
370
413
->willReturn ($ customQueue )
371
414
;
@@ -397,6 +440,47 @@ public function testShouldBindQueuesOnlyOnce()
397
440
$ tester ->execute ([]);
398
441
}
399
442
443
+ public function testShouldNotBindExternalRoutes ()
444
+ {
445
+ $ defaultQueue = new NullQueue ('' );
446
+
447
+ $ routeCollection = new RouteCollection ([
448
+ new Route ('barTopic ' , Route::TOPIC , 'processor ' , ['queue ' => null ]),
449
+ new Route ('fooTopic ' , Route::TOPIC , 'processor ' , ['queue ' => 'external_queue ' , 'external ' => true ]),
450
+ ]);
451
+
452
+ $ processor = $ this ->createDelegateProcessorMock ();
453
+
454
+ $ driver = $ this ->createDriverStub ($ routeCollection );
455
+ $ driver
456
+ ->expects ($ this ->exactly (1 ))
457
+ ->method ('createQueue ' )
458
+ ->with ('default ' , true )
459
+ ->willReturn ($ defaultQueue )
460
+ ;
461
+
462
+ $ consumer = $ this ->createQueueConsumerMock ();
463
+ $ consumer
464
+ ->expects ($ this ->exactly (1 ))
465
+ ->method ('bind ' )
466
+ ->with ($ this ->identicalTo ($ defaultQueue ), $ this ->identicalTo ($ processor ))
467
+ ;
468
+ $ consumer
469
+ ->expects ($ this ->at (1 ))
470
+ ->method ('consume ' )
471
+ ->with ($ this ->isInstanceOf (ChainExtension::class))
472
+ ;
473
+
474
+ $ command = new ConsumeCommand (new Container ([
475
+ 'enqueue.client.default.queue_consumer ' => $ consumer ,
476
+ 'enqueue.client.default.driver ' => $ driver ,
477
+ 'enqueue.client.default.delegate_processor ' => $ processor ,
478
+ ]));
479
+
480
+ $ tester = new CommandTester ($ command );
481
+ $ tester ->execute ([]);
482
+ }
483
+
400
484
public function testShouldSkipQueueConsumptionAndUseCustomClientDestinationName ()
401
485
{
402
486
$ queue = new NullQueue ('' );
@@ -423,19 +507,19 @@ public function testShouldSkipQueueConsumptionAndUseCustomClientDestinationName(
423
507
$ driver = $ this ->createDriverStub ($ routeCollection );
424
508
$ driver
425
509
->expects ($ this ->at (3 ))
426
- ->method ('createQueue ' )
510
+ ->method ('createQueue ' , true )
427
511
->with ('default ' )
428
512
->willReturn ($ queue )
429
513
;
430
514
$ driver
431
515
->expects ($ this ->at (4 ))
432
- ->method ('createQueue ' )
516
+ ->method ('createQueue ' , true )
433
517
->with ('fooQueue ' )
434
518
->willReturn ($ queue )
435
519
;
436
520
$ driver
437
521
->expects ($ this ->at (5 ))
438
- ->method ('createQueue ' )
522
+ ->method ('createQueue ' , true )
439
523
->with ('ololoQueue ' )
440
524
->willReturn ($ queue )
441
525
;
0 commit comments