Commit 18d44b50 authored by catch's avatar catch

Issue #2351919 by almaudoh, Wim Leers, claudiu.cristea: Replace uses of...

Issue #2351919 by almaudoh, Wim Leers, claudiu.cristea: Replace uses of drupal_get_path() with __DIR__  or Extension::getPath() where possible
parent 0ef9ecf7
......@@ -59,7 +59,7 @@ public function testFeed($use_last_modified, $use_etag, Request $request) {
$response->headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
// Read actual feed from file.
$file_name = drupal_get_path('module', 'aggregator_test') . '/aggregator_test_rss091.xml';
$file_name = __DIR__ . '/../../aggregator_test_rss091.xml';
$handle = fopen($file_name, 'r');
$feed = fread($handle, filesize($file_name));
fclose($handle);
......
......@@ -345,7 +345,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
'init_message' => t('Starting configuration synchronization.'),
'progress_message' => t('Completed step @current of @total.'),
'error_message' => t('Configuration synchronization has encountered an error.'),
'file' => drupal_get_path('module', 'config') . '/config.admin.inc',
'file' => __DIR__ . '/../../config.admin.inc',
);
foreach ($sync_steps as $sync_step) {
$batch['operations'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step));
......
......@@ -388,8 +388,8 @@ public function testConfigSaveWithSchema() {
// Ensure that configuration objects with keys marked as ignored are not
// changed when saved. The 'config_schema_test.ignore' will have been saved
// during the installation of configuration in the setUp method.
$extension_path = drupal_get_path('module', 'config_schema_test');
$install_storage = new FileStorage($extension_path . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY);
$extension_path = __DIR__ . '/../../tests/config_schema_test/';
$install_storage = new FileStorage($extension_path . InstallStorage::CONFIG_INSTALL_DIRECTORY);
$original_data = $install_storage->read('config_schema_test.ignore');
$installed_data = $this->config('config_schema_test.ignore')->get();
unset($installed_data['_core']);
......
......@@ -933,7 +933,7 @@ function testUrlFilterContent() {
'filter_url_length' => 496,
)
));
$path = drupal_get_path('module', 'filter') . '/tests';
$path = __DIR__ . '/../../tests';
$input = file_get_contents($path . '/filter.url-input.txt');
$expected = file_get_contents($path . '/filter.url-output.txt');
......
......@@ -38,8 +38,8 @@ protected function setUp() {
$this->drupalLogin($this->adminUser);
// Copy test po files to the translations directory.
file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(__DIR__ . '/../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(__DIR__ . '/../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
}
/**
......
......@@ -46,8 +46,8 @@ protected function setUp() {
parent::setUp();
// Copy test po files to the translations directory.
file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(__DIR__ . '/../../tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE);
file_unmanaged_copy(__DIR__ . '/../../tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE);
$this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages'));
$this->adminUserAccessSiteReports = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'access site reports'));
......
......@@ -26,7 +26,7 @@ class LocaleJavascriptTranslationTest extends WebTestBase {
public static $modules = array('locale', 'locale_test');
public function testFileParsing() {
$filename = drupal_get_path('module', 'locale') . '/tests/locale_test.js';
$filename = __DIR__ . '/../../tests/locale_test.js';
// Parse the file to look for source strings.
_locale_parse_js_file($filename);
......
......@@ -251,7 +251,7 @@ public static function preRenderCacheTags($elements) {
*/
public function authorizeInit($page_title) {
$authorize_url = Url::fromUri('base:core/authorize.php', array('absolute' => TRUE))->toString();
system_authorized_init('system_test_authorize_run', drupal_get_path('module', 'system_test') . '/system_test.module', array(), $page_title);
system_authorized_init('system_test_authorize_run', __DIR__ . '/../../system_test.module', array(), $page_title);
return new RedirectResponse($authorize_url);
}
......
......@@ -245,7 +245,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// The page title must be passed here to ensure it is initially used when
// authorize.php loads for the first time with the FTP/SSH credentials
// form.
system_authorized_init('update_authorize_run_install', drupal_get_path('module', 'update') . '/update.authorize.inc', $arguments, $this->t('Update manager'));
system_authorized_init('update_authorize_run_install', __DIR__ . '/../../update.authorize.inc', $arguments, $this->t('Update manager'));
$form_state->setRedirectUrl(system_authorized_get_url());
}
}
......
......@@ -169,7 +169,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// The page title must be passed here to ensure it is initially used
// when authorize.php loads for the first time with the FTP/SSH
// credentials form.
system_authorized_init('update_authorize_run_update', drupal_get_path('module', 'update') . '/update.authorize.inc', array($updates), $this->t('Update manager'));
system_authorized_init('update_authorize_run_update', __DIR__ . '/../../update.authorize.inc', array($updates), $this->t('Update manager'));
$form_state->setRedirectUrl(system_authorized_get_url());
}
}
......
......@@ -52,7 +52,7 @@ public function testUploadModule() {
// Check to ensure an existing module can't be reinstalled. Also checks that
// the archive was extracted since we can't know if the module is already
// installed until after extraction.
$validArchiveFile = drupal_get_path('module', 'update') . '/tests/aaa_update_test.tar.gz';
$validArchiveFile = __DIR__ . '/../../tests/aaa_update_test.tar.gz';
$edit = array(
'files[project_upload]' => $validArchiveFile,
);
......@@ -65,7 +65,7 @@ public function testUploadModule() {
$moduleUpdater = $updaters['module']['class'];
$installedInfoFilePath = $this->container->get('update.root') . '/' . $moduleUpdater::getRootDirectoryRelativePath() . '/update_test_new_module/update_test_new_module.info.yml';
$this->assertFalse(file_exists($installedInfoFilePath), 'The new module does not exist in the filesystem before it is installed with the Update Manager.');
$validArchiveFile = drupal_get_path('module', 'update') . '/tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
$validArchiveFile = __DIR__ . '/../../tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz';
$edit = array(
'files[project_upload]' => $validArchiveFile,
);
......
......@@ -68,8 +68,7 @@ public function updateTest($project_name, $version) {
$availability_scenario = '#broken#';
}
$path = drupal_get_path('module', 'update_test');
$file = "$path/$project_name.$availability_scenario.xml";
$file = __DIR__ . "/../../$project_name.$availability_scenario.xml";
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
if (!is_file($file)) {
// Return an empty response.
......
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