function DrupalKernel::setupDrupalTestInChildSite
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::setupDrupalTestInChildSite()
Define the DRUPAL_TEST_IN_CHILD_SITE constant as appropriate.
@internal This method is only intended to be called by this class and \Drupal\Core\Command\DrupalApplication. We aim to remove the need for it without a BC layer during Drupal 12.
Parameters
string $app_root: The path to the application root.
See also
https://www.drupal.org/node/2690035
1 call to DrupalKernel::setupDrupalTestInChildSite()
- DrupalApplication::bootstrap in core/
lib/ Drupal/ Core/ Command/ DrupalApplication.php - Bootstraps Drupal in a way that is appropriate for console commands.
File
-
core/
lib/ Drupal/ Core/ DrupalKernel.php, line 1188
Class
- DrupalKernel
- The DrupalKernel class is the core of Drupal itself.
Namespace
Drupal\CoreCode
public static function setupDrupalTestInChildSite(string $app_root) : void {
// Indicate if code is operating in a test child site or not.
if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
if ($test_prefix = drupal_valid_test_ua()) {
$test_db = new TestDatabase($test_prefix);
// Only code that interfaces directly with tests should rely on this
// constant; e.g., the error/exception handler conditionally adds
// further error information into HTTP response headers that are
// consumed by the internal browser.
define('DRUPAL_TEST_IN_CHILD_SITE', TRUE);
// Log fatal errors to the test site directory.
ini_set('log_errors', 1);
ini_set('error_log', $app_root . '/' . $test_db->getTestSitePath() . '/error.log');
// Ensure that a rewritten settings.php is used if OPcache is on.
ini_set('opcache.validate_timestamps', 'on');
ini_set('opcache.revalidate_freq', 0);
}
else {
// Ensure that no other code defines this.
define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.