You are here

public function KernelTestBase::__get in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::__get()

BC: Automatically resolve former KernelTestBase class properties.

Test authors should follow the provided instructions and adjust their tests accordingly.

Deprecated

in Drupal 8.0.x, will be removed before Drupal 8.2.0.

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 1064
Contains \Drupal\KernelTests\KernelTestBase.

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

public function __get($name) {
  if (in_array($name, array(
    'public_files_directory',
    'private_files_directory',
    'temp_files_directory',
    'translation_files_directory',
  ))) {

    // @comment it in again.
    trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use the regular API method to retrieve it instead (e.g., Settings).", $name), E_USER_DEPRECATED);
    switch ($name) {
      case 'public_files_directory':
        return Settings::get('file_public_path', \Drupal::service('site.path') . '/files');
      case 'private_files_directory':
        return $this->container
          ->get('config.factory')
          ->get('system.file')
          ->get('path.private');
      case 'temp_files_directory':
        return file_directory_temp();
      case 'translation_files_directory':
        return Settings::get('file_public_path', \Drupal::service('site.path') . '/translations');
    }
  }
  if ($name === 'configDirectories') {
    trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED);
    return array(
      CONFIG_SYNC_DIRECTORY => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
    );
  }
  $denied = array(
    // @see \Drupal\simpletest\TestBase
    'testId',
    'timeLimit',
    'results',
    'assertions',
    'skipClasses',
    'verbose',
    'verboseId',
    'verboseClassName',
    'verboseDirectory',
    'verboseDirectoryUrl',
    'dieOnFail',
    'kernel',
    // @see \Drupal\simpletest\TestBase::prepareEnvironment()
    'generatedTestFiles',
    // @see \Drupal\simpletest\KernelTestBase::containerBuild()
    'keyValueFactory',
  );
  if (in_array($name, $denied) || strpos($name, 'original') === 0) {
    throw new \RuntimeException(sprintf('TestBase::$%s property no longer exists', $name));
  }
}