You are here

trait RedisTestInterfaceTrait in Redis 8

Hierarchy

6 files declare their use of RedisTestInterfaceTrait
RedisCacheTest.php in tests/src/Kernel/RedisCacheTest.php
RedisFloodTest.php in tests/src/Kernel/RedisFloodTest.php
RedisLockFunctionalTest.php in tests/src/Functional/Lock/RedisLockFunctionalTest.php
RedisLockTest.php in tests/src/Kernel/RedisLockTest.php
RedisQueueTest.php in tests/src/Kernel/RedisQueueTest.php

... See full list

File

tests/src/Traits/RedisTestInterfaceTrait.php, line 7

Namespace

Drupal\Tests\redis\Traits
View source
trait RedisTestInterfaceTrait {

  /**
   * Uses an env variable to set the redis client to use for this test.
   */
  public function setUpSettings() {

    // Write redis_interface settings manually.
    $redis_interface = self::getRedisInterfaceEnv();
    $settings = Settings::getAll();
    $settings['redis.connection']['interface'] = $redis_interface;
    new Settings($settings);
  }

  /**
   * Uses an env variable to set the redis client to use for this test.
   */
  public function getRedisInterfaceEnv() {

    // Get REDIS_INTERFACE from env variable.
    $redis_interface = getenv('REDIS_INTERFACE');

    // Default to PhpRedis is env variable not available.
    if ($redis_interface == FALSE) {
      $redis_interface = 'PhpRedis';
    }
    return $redis_interface;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RedisTestInterfaceTrait::getRedisInterfaceEnv public function Uses an env variable to set the redis client to use for this test.
RedisTestInterfaceTrait::setUpSettings public function Uses an env variable to set the redis client to use for this test.