You are here

protected function RedisLockFunctionalTest::setUp in Redis 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/Lock/RedisLockFunctionalTest.php, line 30

Class

RedisLockFunctionalTest
Confirm locking works between two separate requests.

Namespace

Drupal\Tests\redis\Functional\Lock

Code

protected function setUp() {
  parent::setUp();

  // Write the containers_yaml update by hand, since writeSettings() doesn't
  // support this syntax.
  $filename = $this->siteDirectory . '/settings.php';
  chmod($filename, 0666);
  $contents = file_get_contents($filename);
  $redis_interface = self::getRedisInterfaceEnv();
  $module_path = drupal_get_path('module', 'redis');
  $contents .= "\n\n" . "\$settings['container_yamls'][] = '{$module_path}/example.services.yml';";
  $contents .= "\n\n" . '$settings["redis.connection"]["interface"] = \'' . $redis_interface . '\';';
  file_put_contents($filename, $contents);
  $settings = Settings::getAll();
  $settings['container_yamls'][] = $module_path . '/example.services.yml';
  $settings['redis.connection']['interface'] = $redis_interface;
  new Settings($settings);
  OpCodeCache::invalidate(DRUPAL_ROOT . '/' . $filename);
  $this
    ->rebuildContainer();

  // Get database schema.
  $db_schema = Database::getConnection()
    ->schema();

  // Make sure that the semaphore table isn't used.
  $db_schema
    ->dropTable('semaphore');
}