MCPcopy Create free account
hub / github.com/taskforcesh/bullmq / testCanShareConnection

Method testCanShareConnection

php/tests/QueueTest.php:361–389  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

359 }
360
361 public function testCanShareConnection(): void
362 {
363 $connection = new RedisConnection([
364 'host' => getenv('REDIS_HOST') ?: 'localhost',
365 'port' => (int)(getenv('REDIS_PORT') ?: 6379),
366 ]);
367
368 $queue1 = new Queue('shared-conn-queue-1', ['connection' => $connection]);
369 $queue2 = new Queue('shared-conn-queue-2', ['connection' => $connection]);
370
371 $job1 = $queue1->add('job-1', ['queue' => 1]);
372 $job2 = $queue2->add('job-2', ['queue' => 2]);
373
374 $this->assertNotNull($job1->id);
375 $this->assertNotNull($job2->id);
376
377 $queue1->obliterate(['force' => true]);
378 $queue2->obliterate(['force' => true]);
379
380 // Queues don't own the connection, so they shouldn't close it
381 $queue1->close();
382 $queue2->close();
383
384 // Connection should still be usable
385 $result = $connection->getClient()->ping();
386 $this->assertNotNull($result);
387
388 $connection->close();
389 }
390
391 public function testGetJobsByMultipleTypes(): void
392 {

Callers

nothing calls this directly

Calls 5

pingMethod · 0.80
getClientMethod · 0.80
addMethod · 0.65
obliterateMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected