Commit c00b97b2 authored by catch's avatar catch

Issue #2928710 by borisson_, dawehner, idebr: Eliminate usages of \Drupal::root() in tests

parent a26816d1
......@@ -205,7 +205,7 @@ public function testBigPipe() {
$this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent: error occurred before then.');
$this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
// The exception is expected. Do not interpret it as a test failure.
unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
unlink($this->root . '/' . $this->siteDirectory . '/error.log');
}
/**
......@@ -273,7 +273,7 @@ public function testBigPipeNoJs() {
$this->assertRaw('You are not allowed to say llamas are not cool!');
$this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
// The exception is expected. Do not interpret it as a test failure.
unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
unlink($this->root . '/' . $this->siteDirectory . '/error.log');
}
/**
......
......@@ -112,7 +112,7 @@ public function testMainProperty() {
* Enable all core modules.
*/
protected function enableAllCoreModules() {
$listing = new ExtensionDiscovery(\Drupal::root());
$listing = new ExtensionDiscovery($this->root);
$module_list = $listing->scan('module', FALSE);
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
$module_handler = $this->container->get('module_handler');
......
......@@ -30,7 +30,7 @@ protected function prepareMigration(MigrationInterface $migration) {
// Make sure we have a single trailing slash.
$source = $migration->getSourceConfiguration();
$source['site_path'] = 'core/modules/simpletest';
$source['constants']['source_base_path'] = \Drupal::root() . '/';
$source['constants']['source_base_path'] = $this->root . '/';
$migration->set('source', $source);
}
}
......
......@@ -67,7 +67,7 @@ protected function setUp() {
'file_extensions' => 'jpg',
],
])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create([
'uri' => 'public://example.jpg',
]);
......@@ -100,7 +100,7 @@ public function testImageItem() {
$this->assertEqual($entity->image_test->entity->uuid(), $this->image->uuid());
// Make sure the computed entity reflects updates to the referenced file.
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example-2.jpg');
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', 'public://example-2.jpg');
$image2 = File::create([
'uri' => 'public://example-2.jpg',
]);
......
......@@ -62,7 +62,7 @@ protected function setUp() {
'field_name' => 'image_test',
'bundle' => 'entity_test',
])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create([
'uri' => 'public://example.jpg',
]);
......
......@@ -135,7 +135,7 @@ public function testImageMediaRevision() {
$this->drupalGet('/media/add/image');
$page = $this->getSession()->getPage();
$page->fillField('Name', 'Foobar');
$page->attachFileToField('Image', \Drupal::root() . '/core/modules/media/tests/fixtures/example_1.jpeg');
$page->attachFileToField('Image', $this->root . '/core/modules/media/tests/fixtures/example_1.jpeg');
$page->pressButton('Save');
$assert->addressMatches('/^\/media\/[0-9]+$/');
......
......@@ -68,7 +68,7 @@ public function testMediaDisplay() {
$this->drupalGet('media/add/image');
$image_media_name = 'Fantastic image asset!';
$page->fillField('name[0][value]', $image_media_name);
$page->attachFileToField('files[field_media_image_0]', \Drupal::root() . '/core/modules/media/tests/fixtures/example_1.jpeg');
$page->attachFileToField('files[field_media_image_0]', $this->root . '/core/modules/media/tests/fixtures/example_1.jpeg');
$result = $assert_session->waitForButton('Remove');
$this->assertNotEmpty($result);
$page->fillField('field_media_image[0][alt]', 'Image Alt Text 1');
......
......@@ -46,7 +46,7 @@ public function testMediaImageSource() {
// Create a media item.
$this->drupalGet("media/add/{$media_type_id}");
$page->attachFileToField("files[{$source_field_id}_0]", \Drupal::root() . '/core/modules/media/tests/fixtures/example_1.jpeg');
$page->attachFileToField("files[{$source_field_id}_0]", $this->root . '/core/modules/media/tests/fixtures/example_1.jpeg');
$result = $assert_session->waitForButton('Remove');
$this->assertNotEmpty($result);
$page->fillField("{$source_field_id}[0][alt]", 'Image Alt Text 1');
......
......@@ -136,7 +136,7 @@ protected function setUp() {
$this->term->save();
// Create image.
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create(['uri' => 'public://example.jpg']);
$this->image->save();
......
......@@ -20,7 +20,7 @@ public function testSearchSimplifyUnicode() {
// their own lines). So the even-numbered lines should simplify to nothing,
// and the odd-numbered lines we need to split into shorter chunks and
// verify that simplification doesn't lose any characters.
$input = file_get_contents(\Drupal::root() . '/core/modules/search/tests/UnicodeTest.txt');
$input = file_get_contents($this->root . '/core/modules/search/tests/UnicodeTest.txt');
$basestrings = explode(chr(10), $input);
$strings = [];
foreach ($basestrings as $key => $string) {
......
......@@ -104,7 +104,7 @@ public function testEarlyRendering() {
// The exceptions are expected. Do not interpret them as a test failure.
// Not using File API; a potential error must trigger a PHP warning.
unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
unlink($this->root . '/' . $this->siteDirectory . '/error.log');
}
}
......@@ -20,7 +20,7 @@ class FileTransferTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
$this->testConnection = TestFileTransfer::factory(\Drupal::root(), ['hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port]);
$this->testConnection = TestFileTransfer::factory($this->root, ['hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port]);
}
public function _getFakeModuleFiles() {
......@@ -82,7 +82,7 @@ public function testJail() {
$gotit = TRUE;
try {
$this->testConnection->copyDirectory($source, \Drupal::root() . '/' . PublicStream::basePath());
$this->testConnection->copyDirectory($source, $this->root . '/' . PublicStream::basePath());
}
catch (FileTransferException $e) {
$gotit = FALSE;
......
......@@ -21,7 +21,7 @@ class DependencyHookInvocationTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
}
/**
......
......@@ -22,7 +22,7 @@ protected function setUp() {
// Only install update_test_2.module, even though its updates have a
// dependency on update_test_3.module.
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
}
public function testMissingUpdate() {
......
......@@ -20,7 +20,7 @@ class DependencyOrderingTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
}
/**
......
......@@ -35,7 +35,7 @@ class InvalidUpdateHookTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
$this->updateUrl = $GLOBALS['base_url'] . '/update.php';
$this->updateUser = $this->drupalCreateUser(['administer software updates']);
......
......@@ -35,7 +35,7 @@ class UpdateSchemaTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
$this->user = $this->drupalCreateUser(['administer software updates', 'access site in maintenance mode']);
$this->updateUrl = Url::fromRoute('system.db_update');
}
......
......@@ -31,7 +31,7 @@ class UpdatesWith7xTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
$this->updateUrl = $GLOBALS['base_url'] . '/update.php';
$this->updateUser = $this->drupalCreateUser(['administer software updates']);
}
......
......@@ -33,13 +33,13 @@ public function testDirectoryPrecedence() {
foreach ($expected_directories as $module => $directories) {
foreach ($directories as $directory) {
$filename = "$directory/$module/$module.info.yml";
$this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', ['@filename' => $filename]));
$this->assertTrue(file_exists($this->root . '/' . $filename), format_string('@filename exists.', ['@filename' => $filename]));
}
}
// Now scan the directories and check that the files take precedence as
// expected.
$listing = new ExtensionDiscovery(\Drupal::root());
$listing = new ExtensionDiscovery($this->root);
$listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
foreach ($expected_directories as $module => $directories) {
......@@ -56,7 +56,7 @@ public function testDirectoryPrecedence() {
* Tests that directories matching file_scan_ignore_directories are ignored
*/
public function testFileScanIgnoreDirectory() {
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
$listing = new ExtensionDiscovery($this->root, FALSE);
$listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayHasKey('drupal_system_listing_compatible_test', $files);
......@@ -68,7 +68,7 @@ public function testFileScanIgnoreDirectory() {
$reflected_property->setValue($reflected_class, []);
$this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']);
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
$listing = new ExtensionDiscovery($this->root, FALSE);
$listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayNotHasKey('drupal_system_listing_compatible_test', $files);
......
......@@ -164,7 +164,7 @@ public function testUninstallReinstall() {
// installed for testing below.
$this->vocabulary->unsetThirdPartySetting('taxonomy_crud', 'foo');
require_once \Drupal::root() . '/core/includes/install.inc';
require_once $this->root . '/core/includes/install.inc';
$this->container->get('module_installer')->uninstall(['taxonomy']);
$this->container->get('module_installer')->install(['taxonomy']);
......
......@@ -190,10 +190,10 @@ public function testUpdateManagerCoreSecurityUpdateMessages() {
* Tests only an *.info.yml file are detected without supporting files.
*/
public function testUpdateDirectory() {
$type = Updater::getUpdaterFromDirectory(\Drupal::root() . '/core/modules/update/tests/modules/aaa_update_test');
$type = Updater::getUpdaterFromDirectory($this->root . '/core/modules/update/tests/modules/aaa_update_test');
$this->assertEqual($type, 'Drupal\\Core\\Updater\\Module', 'Detected a Module');
$type = Updater::getUpdaterFromDirectory(\Drupal::root() . '/core/modules/update/tests/themes/update_test_basetheme');
$type = Updater::getUpdaterFromDirectory($this->root . '/core/modules/update/tests/themes/update_test_basetheme');
$this->assertEqual($type, 'Drupal\\Core\\Updater\\Theme', 'Detected a Theme.');
}
......
......@@ -24,8 +24,8 @@ class UserAccountFormFieldsTest extends KernelTestBase {
* Tests the root user account form section in the "Configure site" form.
*/
public function testInstallConfigureForm() {
require_once \Drupal::root() . '/core/includes/install.core.inc';
require_once \Drupal::root() . '/core/includes/install.inc';
require_once $this->root . '/core/includes/install.core.inc';
require_once $this->root . '/core/includes/install.inc';
$install_state = install_state_defaults();
$form_state = new FormState();
$form_state->addBuildInfo('args', [&$install_state]);
......
......@@ -21,8 +21,8 @@ class InstallerLanguageDirectionTest extends InstallerTestBase {
*/
protected function setUpLanguage() {
// Place a custom local translation in the translations directory.
mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.ar.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue Arabic\"");
mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.ar.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue Arabic\"");
parent::setUpLanguage();
// After selecting a different language than English, all following screens
......
......@@ -16,8 +16,8 @@ class InstallerLanguagePageTest extends InstallerTestBase {
*/
protected function setUpLanguage() {
// Place a custom local translation in the translations directory.
mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
touch(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.xoxo.po');
mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
touch($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.xoxo.po');
// Check that all predefined languages show up with their native names.
$this->visitInstaller();
......
......@@ -19,7 +19,7 @@ public function testInstaller() {
$this->assertText($this->rootUser->getUsername());
// Verify that the confirmation message appears.
require_once \Drupal::root() . '/core/includes/install.inc';
require_once $this->root . '/core/includes/install.inc';
$this->assertRaw(t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
]));
......
......@@ -23,8 +23,8 @@ class InstallerTranslationQueryTest extends InstallerTestBase {
*/
protected function visitInstaller() {
// Place a custom local translation in the translations directory.
mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
// The unrouted URL assembler does not exist at this point, so we build the
// URL ourselves.
......
......@@ -24,8 +24,8 @@ class InstallerTranslationTest extends InstallerTestBase {
*/
protected function setUpLanguage() {
// Place a custom local translation in the translations directory.
mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
parent::setUpLanguage();
......
......@@ -193,7 +193,7 @@ protected function setUp() {
$this->replaceUser1();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
// Setup Mink.
$session = $this->initMink();
......
......@@ -149,7 +149,6 @@ public function testCoreLibraryCompleteness() {
* so on.
*/
protected function verifyLibraryFilesExist($library_definitions) {
$root = \Drupal::root();
foreach ($library_definitions as $extension => $libraries) {
foreach ($libraries as $library_name => $library) {
if (in_array("$extension/$library_name", $this->librariesToSkip)) {
......@@ -160,7 +159,7 @@ protected function verifyLibraryFilesExist($library_definitions) {
foreach (['css', 'js'] as $asset_type) {
foreach ($library[$asset_type] as $asset) {
$file = $asset['data'];
$path = $root . '/' . $file;
$path = $this->root . '/' . $file;
// Only check and assert each file path once.
if (!isset($this->pathsChecked[$path])) {
$this->assertTrue(is_file($path), "$file file referenced from the $extension/$library_name library exists.");
......@@ -192,10 +191,9 @@ protected function getAllLibraries() {
$libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');
$root = \Drupal::root();
foreach ($extensions as $extension_name => $extension) {
$library_file = $extension->getPath() . '/' . $extension_name . '.libraries.yml';
if (is_file($root . '/' . $library_file)) {
if (is_file($this->root . '/' . $library_file)) {
$libraries[$extension_name] = $this->libraryDiscovery->getLibrariesByExtension($extension_name);
}
}
......
......@@ -28,7 +28,7 @@ public function testSystemInitIgnoresSecondaries() {
Database::addConnectionInfo('default', 'replica', $connection_info['default']);
db_ignore_replica();
$class_loader = require \Drupal::root() . '/autoload.php';
$class_loader = require $this->root . '/autoload.php';
$kernel = new DrupalKernel('testing', $class_loader, FALSE);
$event = new GetResponseEvent($kernel, Request::create('http://example.com'), HttpKernelInterface::MASTER_REQUEST);
$subscriber = new ReplicaDatabaseIgnoreSubscriber();
......
......@@ -73,8 +73,8 @@ protected function setUp() {
],
];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
$base_directory2 = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test_extended/src';
$base_directory = $this->root . '/core/modules/system/tests/modules/plugin_test/src';
$base_directory2 = $this->root . '/core/modules/system/tests/modules/plugin_test_extended/src';
$namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory, 'Drupal\plugin_test_extended' => $base_directory2]);
$annotation_namespaces = ['Drupal\plugin_test\Plugin\Annotation', 'Drupal\plugin_test_extended\Plugin\Annotation'];
......
......@@ -30,7 +30,7 @@ protected function setUp() {
],
];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
$base_directory = $this->root . '/core/modules/system/tests/modules/plugin_test/src';
$root_namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory]);
$this->discovery = new AnnotatedClassDiscovery('Plugin/plugin_test/custom_annotation', $root_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample');
......
......@@ -80,7 +80,7 @@ protected function setUp() {
],
];
$base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src';
$base_directory = $this->root . '/core/modules/system/tests/modules/plugin_test/src';
$namespaces = new \ArrayObject(['Drupal\plugin_test' => $base_directory]);
$this->discovery = new AnnotatedClassDiscovery('', $namespaces);
......
......@@ -42,7 +42,7 @@ protected function setUp() {
// as derivatives and ReflectionFactory.
$this->testPluginManager = new TestPluginManager();
$this->mockBlockManager = new MockBlockManager();
$module_handler = new ModuleHandler(\Drupal::root(), [], new MemoryBackend(), $this->container->get('event_dispatcher'));
$module_handler = new ModuleHandler($this->root, [], new MemoryBackend(), $this->container->get('event_dispatcher'));
$this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler);
// The expected plugin definitions within each manager. Several tests assert
......
......@@ -53,7 +53,7 @@ public function testProcessOutbound() {
// Test request with subdir on homepage.
$server = [
'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir', 'GET', [], [], [], $server);
......@@ -70,7 +70,7 @@ public function testProcessOutbound() {
// Test request with subdir on other page.
$server = [
'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir/node/add', 'GET', [], [], [], $server);
......@@ -87,7 +87,7 @@ public function testProcessOutbound() {
// Test request without subdir on the homepage.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/', 'GET', [], [], [], $server);
......@@ -104,7 +104,7 @@ public function testProcessOutbound() {
// Test request without subdir on other page.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/node/add', 'GET', [], [], [], $server);
......
......@@ -54,7 +54,7 @@ public function testProcessOutbound() {
// Test request with subdir on homepage.
$server = [
'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir/', 'GET', [], [], [], $server);
......@@ -69,7 +69,7 @@ public function testProcessOutbound() {
// Test request with subdir on other page.
$server = [
'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/subdir/node/add', 'GET', [], [], [], $server);
......@@ -84,7 +84,7 @@ public function testProcessOutbound() {
// Test request without subdir on the homepage.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/', 'GET', [], [], [], $server);
......@@ -99,7 +99,7 @@ public function testProcessOutbound() {
// Test request without subdir on other page.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/node/add', 'GET', [], [], [], $server);
......@@ -115,7 +115,7 @@ public function testProcessOutbound() {
// not found exception page.
$server = [
'SCRIPT_NAME' => '/index.php',
'SCRIPT_FILENAME' => \Drupal::root() . '/index.php',
'SCRIPT_FILENAME' => $this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::create('/invalid-path', 'GET', [], [], [], $server);
......
......@@ -16,7 +16,7 @@ class SettingsRewriteTest extends KernelTestBase {
* Tests the drupal_rewrite_settings() function.
*/
public function testDrupalRewriteSettings() {
include_once \Drupal::root() . '/core/includes/install.inc';
include_once $this->root . '/core/includes/install.inc';
$site_path = $this->container->get('site.path');
$tests = [
[
......
......@@ -69,11 +69,11 @@ public function testMultipleSubThemes() {
$theme_handler = \Drupal::service('theme_handler');
$theme_handler->install(['test_basetheme', 'test_subtheme', 'test_subsubtheme']);
$registry_subsub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subsubtheme');
$registry_subsub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subsubtheme');
$registry_subsub_theme->setThemeManager(\Drupal::theme());
$registry_sub_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subtheme');
$registry_sub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subtheme');
$registry_sub_theme->setThemeManager(\Drupal::theme());
$registry_base_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_basetheme');
$registry_base_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_basetheme');
$registry_base_theme->setThemeManager(\Drupal::theme());
$preprocess_functions = $registry_subsub_theme->get()['theme_test_template_test']['preprocess functions'];
......@@ -111,7 +111,7 @@ public function testSuggestionPreprocessFunctions() {
$theme_handler = \Drupal::service('theme_handler');
$theme_handler->install(['test_theme']);
$registry_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry_theme->setThemeManager(\Drupal::theme());
$suggestions = ['__kitten', '__flamingo'];
......@@ -154,7 +154,7 @@ public function testThemeRegistryAlterByTheme() {
$theme_handler->install(['test_theme']);
$this->config('system.theme')->set('default', 'test_theme')->save();
$registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry->setThemeManager(\Drupal::theme());
$this->assertEqual('value', $registry->get()['theme_test_template_test']['variables']['additional']);
}
......@@ -199,7 +199,7 @@ public function testThemeTemplatesRegisteredByModules() {
$theme_handler = \Drupal::service('theme_handler');
$theme_handler->install(['test_theme']);
$registry_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry_theme->setThemeManager(\Drupal::theme());
$expected = [
......
......@@ -94,7 +94,6 @@ public function testStableLibraryOverrides() {
$libraries_after = $this->getAllLibraries();
$libraries_after = $this->removeVendorAssets($libraries_after);
$root = \Drupal::root();
foreach ($libraries_before as $extension => $libraries) {
foreach ($libraries as $library_name => $library) {
// Allow skipping libraries.
......@@ -173,10 +172,9 @@ protected function getAllLibraries() {
$libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');
$root = \Drupal::root();
foreach ($modules as $module_name => $module) {
$library_file = $module->getPath() . '/' . $module_name . '.libraries.yml';
if (is_file($root . '/' . $library_file)) {
if (is_file($this->root . '/' . $library_file)) {
$libraries[$module_name] = $this->libraryDiscovery->getLibrariesByExtension($module_name);
}
}
......
......@@ -82,7 +82,7 @@ protected function installAllModules() {
* Ensures that Stable overrides all relevant core templates.
*/
public function testStableTemplateOverrides() {
$registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $this->themeHandler, \Drupal::service('theme.initialization'), 'stable');
$registry = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $this->themeHandler, \Drupal::service('theme.initialization'), 'stable');
$registry->setThemeManager(\Drupal::theme());
$registry_full = $registry->get();
......
......@@ -33,7 +33,7 @@ protected function setUp() {
$this->installConfig(['system']);
if (!isset($this->availableThemes)) {
$discovery = new ExtensionDiscovery(\Drupal::root());
$discovery = new ExtensionDiscovery($this->root);
$this->availableThemes = $discovery->scan('theme');
}
}
......
......@@ -250,7 +250,7 @@ public function testGetAndSet() {
$files = [];
for ($i = 0; $i < 3; $i++) {
$path = "public://example_$i.png";
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path);
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', $path);
$image = File::create(['uri' => $path]);
$image->save();
$files[] = $image;
......
......@@ -18,7 +18,7 @@ class CompatibilityFixTest extends KernelTestBase {
protected function setUp() {
parent::setUp();
require_once \Drupal::root() . '/core/includes/update.inc';
require_once $this->root . '/core/includes/update.inc';
}
public function testFixCompatibility() {
......
......@@ -24,7 +24,7 @@ class UpdaterTest extends KernelTestBase {
public function testGetProjectTitleWithChild() {
// Get the project title from its directory. If it can't find the title
// it will choose the first project title in the directory.
$directory = \Drupal::root() . '/core/modules/system/tests/modules/module_handler_test_multiple';
$directory = $this->root . '/core/modules/system/tests/modules/module_handler_test_multiple';
$title = Updater::getProjectTitle($directory);
$this->assertEqual('module handler test multiple', $title);
}
......
......@@ -812,7 +812,7 @@ protected function enableModules(array $modules) {
// profile that is not the current profile, and we don't yet have a cached
// way to receive inactive profile information.
// @todo Remove as part of https://www.drupal.org/node/2186491
$listing = new ExtensionDiscovery(\Drupal::root());
$listing = new ExtensionDiscovery($this->root);
$module_list = $listing->scan('module');
// In ModuleHandlerTest we pass in a profile as if it were a module.
$module_list += $listing->scan('profile');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment