You are here

protected function KernelTestBase::prepareConfigDirectories in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/KernelTestBase.php \Drupal\simpletest\KernelTestBase::prepareConfigDirectories()

Create and set new configuration directories.

Throws

\RuntimeException Thrown when CONFIG_SYNC_DIRECTORY cannot be created or made writable.

See also

config_get_config_directory()

2 calls to KernelTestBase::prepareConfigDirectories()
DrupalKernelTest::prepareConfigDirectories in core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
Create and set new configuration directories.
KernelTestBase::setUp in core/modules/simpletest/src/KernelTestBase.php
Performs setup tasks before each individual test method is run.
1 method overrides KernelTestBase::prepareConfigDirectories()
DrupalKernelTest::prepareConfigDirectories in core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php
Create and set new configuration directories.

File

core/modules/simpletest/src/KernelTestBase.php, line 121
Contains \Drupal\simpletest\KernelTestBase.

Class

KernelTestBase
Base class for integration tests.

Namespace

Drupal\simpletest

Code

protected function prepareConfigDirectories() {
  $this->configDirectories = array();
  include_once DRUPAL_ROOT . '/core/includes/install.inc';

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

  // Ensure the directory can be created and is writeable.
  if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
    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;
}