protected function UpdatePathTestBase::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::setUp()
- 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::setUp()
Overrides BrowserTestBase::setUp() for update testing.
The main difference in this method is that rather than performing the installation via the installer, a database is loaded. Additional work is then needed to set various things such as the config directories and the container that would normally be done via the installer.
Overrides BrowserTestBase::setUp
File
- core/
tests/ Drupal/ FunctionalTests/ Update/ UpdatePathTestBase.php, line 128
Class
- UpdatePathTestBase
- Provides a base class for writing an update test.
Namespace
Drupal\FunctionalTests\UpdateCode
protected function setUp() : void {
parent::setUpAppRoot();
$this->zlibInstalled = function_exists('gzopen');
$request = Request::createFromGlobals();
// Boot up Drupal into a state where calling the database API is possible.
// This is used to initialize the database system, so we can load the dump
// files.
$autoloader = (require $this->root . '/autoload.php');
$kernel = TestRunnerKernel::createFromRequest($request, $autoloader);
$kernel
->loadLegacyIncludes();
// Set the update url. This must be set here rather than in
// self::__construct() or the old URL generator will leak additional test
// sites. Additionally, we need to prevent the path alias processor from
// running because we might not have a working alias system before running
// the updates.
$this->updateUrl = Url::fromRoute('system.db_update', [], [
'path_processing' => FALSE,
]);
$this
->setupBaseUrl();
// Install Drupal test site.
$this
->prepareEnvironment();
$this
->runDbTasks();
// We are going to set a missing zlib requirement property for usage
// during the performUpgrade() and tearDown() methods. Also set that the
// tests failed.
if (!$this->zlibInstalled) {
parent::setUp();
return;
}
$this
->installDrupal();
// Add the config directories to settings.php.
$sync_directory = Settings::get('config_sync_directory');
\Drupal::service('file_system')
->prepareDirectory($sync_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
// Ensure the default temp directory exist and is writable. The configured
// temp directory may be removed during update.
\Drupal::service('file_system')
->prepareDirectory($this->tempFilesDirectory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
// Set the container. parent::rebuildAll() would normally do this, but this
// not safe to do here, because the database has not been updated yet.
$this->container = \Drupal::getContainer();
$this
->replaceUser1();
require_once $this->root . '/core/includes/update.inc';
// Setup Mink.
$this
->initMink();
// Set up the browser test output file.
$this
->initBrowserOutputFile();
}