You are here

public function RedisQueueTest::testRedisBlockingQueue in Redis 8

Tests Redis blocking queue.

File

tests/src/Kernel/RedisQueueTest.php, line 62

Class

RedisQueueTest
Tests the Redis queue functions.

Namespace

Drupal\Tests\redis\Kernel

Code

public function testRedisBlockingQueue() {
  self::setUpSettings();

  // Create two queues.
  $client_factory = \Drupal::service('redis.factory');
  $settings = [
    'reserve_timeout' => 30,
  ];
  $class_name = $client_factory
    ->getClass(ClientFactory::REDIS_IMPL_QUEUE);

  /** @var \Drupal\Core\Queue\QueueInterface $queue1 */
  $queue1 = new $class_name($this
    ->randomMachineName(), $settings, $client_factory
    ->getClient());
  $queue1
    ->createQueue();

  /** @var \Drupal\Core\Queue\QueueInterface $queue2 */
  $queue2 = new $class_name($this
    ->randomMachineName(), $settings, $client_factory
    ->getClient());
  $queue2
    ->createQueue();
  $this
    ->runQueueTest($queue1, $queue2);
}