You are here

protected function KernelTestBase::prepareConfigDirectories in Drupal 8

Create and set new configuration directories.

Return value

string The config sync directory path.

Throws

\RuntimeException Thrown when the configuration sync directory cannot be created or made writable.

See also

\Drupal\Core\Site\Settings::getConfigDirectory()

1 call to KernelTestBase::prepareConfigDirectories()
KernelTestBase::setUp in core/modules/simpletest/src/KernelTestBase.php
Performs setup tasks before each individual test method is run.

File

core/modules/simpletest/src/KernelTestBase.php, line 150

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\simpletest

Code

protected function prepareConfigDirectories() {
  $this->configDirectories = [];

  // Assign the relative path to the global variable.
  $path = $this->siteDirectory . '/config_' . CONFIG_SYNC_DIRECTORY;

  // Ensure the directory can be created and is writable.
  if (!\Drupal::service('file_system')
    ->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
    throw new \RuntimeException("Failed to create '" . CONFIG_SYNC_DIRECTORY . "' config directory {$path}");
  }

  // Provide the already resolved path for tests.
  $this->configDirectories[CONFIG_SYNC_DIRECTORY] = $path;
  return $path;
}