Skip to content
Snippets Groups Projects
Commit c00b97b2 authored by catch's avatar catch
Browse files

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

parent a26816d1
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 26 additions and 26 deletions
......@@ -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']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment