public function KernelTestBase::__get in Drupal 8
BC: Automatically resolve former KernelTestBase class properties.
Test authors should follow the provided instructions and adjust their tests accordingly.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0.
File
- core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 1027
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
public function __get($name) {
if (in_array($name, [
'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 Settings::get('file_private_path');
case 'temp_files_directory':
return \Drupal::service('file_system')
->getTempDirectory();
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 Settings::get('config_sync_directory') directly instead.", $name), E_USER_DEPRECATED);
return [
CONFIG_SYNC_DIRECTORY => Settings::get('config_sync_directory'),
];
}
$denied = [
// @see \Drupal\simpletest\TestBase
'testId',
'timeLimit',
'results',
'assertions',
'skipClasses',
'verbose',
'verboseId',
'verboseClassName',
'verboseDirectory',
'verboseDirectoryUrl',
'dieOnFail',
'kernel',
// @see \Drupal\simpletest\TestBase::prepareEnvironment()
'generatedTestFiles',
// Properties from the old KernelTestBase class that has been removed.
'keyValueFactory',
];
if (in_array($name, $denied) || strpos($name, 'original') === 0) {
throw new \RuntimeException(sprintf('TestBase::$%s property no longer exists', $name));
}
}