Problem/Motivation
Bet you didn't know DrupalKernel
has Simpletest in it.
DrupalKernel::bootEnvironment()
says this:
// Indicate that code is operating in a test child site.
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
// Simpletest's internal browser.
define('DRUPAL_TEST_IN_CHILD_SITE', TRUE);
// Web tests are to be conducted with runtime assertions active.
assert_options(ASSERT_ACTIVE, TRUE);
// Now synchronize PHP 5 and 7's handling of assertions as much as
// possible.
Handle::register();
// 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);
}
}
This code fragment exists so that we can test WebTestBase
.
When we eventually deprecate TestBase
/WebTestBase
, we won't be able to deprecate DrupalKernel::bootEnvironment()
.
Proposed resolution
Factor this code out of bootEnvironment()
and into a separate static method which can be deprecated.
Deprecate the new method.
Somehow formally deprecate usages of DRUPAL_TEST_IN_CHILD_SITE
which exists solely to isolate TestBase
and WebTestBase
from themselves during testing.
Remaining tasks
Figure out how to deprecate drupal_valid_test_ua()
and friends.