diff --cc core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index d6bad4a,0171820..0000000 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@@ -167,39 -175,16 +175,39 @@@ class ThemeHandlerTest extends UnitTest // Ensure that the css paths are set with the proper prefix. $this->assertEquals(array( 'screen' => array( - 'css/base/elements.css' => DRUPAL_ROOT . '/core/themes/seven/css/base/elements.css', - 'css/components/admin-list.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/admin-list.css', - 'css/components/admin-options.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/admin-options.css', - 'css/components/admin-panel.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/admin-panel.css', - 'css/components/block-recent-content.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/block-recent-content.css', - 'css/components/branding.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/branding.css', - 'css/components/breadcrumb.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/breadcrumb.css', - 'css/components/buttons.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/buttons.css', - 'css/components/buttons.theme.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/buttons.theme.css', - 'css/components/comments.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/comments.css', - 'css/components/console.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/console.css', - 'css/components/dropbutton.component.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/dropbutton.component.css', - 'css/components/entity-meta.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/entity-meta.css', - 'css/components/field-ui.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/field-ui.css', - 'css/components/form.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/form.css', - 'css/components/help.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/help.css', - 'css/components/menus-and-lists.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/menus-and-lists.css', - 'css/components/modules-page.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/modules-page.css', - 'css/components/node.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/node.css', - 'css/components/page-title.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/page-title.css', - 'css/components/pager.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/pager.css', - 'css/components/skip-link.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/skip-link.css', - 'css/components/tables.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/tables.css', - 'css/components/tabs.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/tabs.css', - 'css/components/tour.theme.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/tour.theme.css', - 'css/components/update-status.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/update-status.css', - 'css/components/views-ui.css' => DRUPAL_ROOT . '/core/themes/seven/css/components/views-ui.css', - 'css/layout/layout.css' => DRUPAL_ROOT . '/core/themes/seven/css/layout/layout.css', - 'css/layout/node-add.css' => DRUPAL_ROOT . '/core/themes/seven/css/layout/node-add.css', - 'css/theme/appearance-page.css' => DRUPAL_ROOT . '/core/themes/seven/css/theme/appearance-page.css', - 'css/seven.base.css' => $this->root . '/core/themes/seven/css/seven.base.css', - 'css/style.css' => $this->root . '/core/themes/seven/css/style.css', - 'css/layout.css' => $this->root . '/core/themes/seven/css/layout.css', ++ 'css/base/elements.css' => $this->root . '/core/themes/seven/css/base/elements.css', ++ 'css/components/admin-list.css' => $this->root . '/core/themes/seven/css/components/admin-list.css', ++ 'css/components/admin-options.css' => $this->root . '/core/themes/seven/css/components/admin-options.css', ++ 'css/components/admin-panel.css' => $this->root . '/core/themes/seven/css/components/admin-panel.css', ++ 'css/components/block-recent-content.css' => $this->root . '/core/themes/seven/css/components/block-recent-content.css', ++ 'css/components/branding.css' => $this->root . '/core/themes/seven/css/components/branding.css', ++ 'css/components/breadcrumb.css' => $this->root . '/core/themes/seven/css/components/breadcrumb.css', + 'css/components/buttons.css' => $this->root . '/core/themes/seven/css/components/buttons.css', + 'css/components/buttons.theme.css' => $this->root . '/core/themes/seven/css/components/buttons.theme.css', ++ 'css/components/comments.css' => $this->root . '/core/themes/seven/css/components/comments.css', ++ 'css/components/console.css' => $this->root . '/core/themes/seven/css/components/console.css', + 'css/components/dropbutton.component.css' => $this->root . '/core/themes/seven/css/components/dropbutton.component.css', ++ 'css/components/entity-meta.css' => $this->root . '/core/themes/seven/css/components/entity-meta.css', ++ 'css/components/field-ui.css' => $this->root . '/core/themes/seven/css/components/field-ui.css', ++ 'css/components/form.css' => $this->root . '/core/themes/seven/css/components/form.css', ++ 'css/components/help.css' => $this->root . '/core/themes/seven/css/components/help.css', ++ 'css/components/menus-and-lists.css' => $this->root . '/core/themes/seven/css/components/menus-and-lists.css', ++ 'css/components/modules-page.css' => $this->root . '/core/themes/seven/css/components/modules-page.css', ++ 'css/components/node.css' => $this->root . '/core/themes/seven/css/components/node.css', ++ 'css/components/page-title.css' => $this->root . '/core/themes/seven/css/components/page-title.css', ++ 'css/components/pager.css' => $this->root . '/core/themes/seven/css/components/pager.css', ++ 'css/components/skip-link.css' => $this->root . '/core/themes/seven/css/components/skip-link.css', ++ 'css/components/tables.css' => $this->root . '/core/themes/seven/css/components/tables.css', ++ 'css/components/tabs.css' => $this->root . '/core/themes/seven/css/components/tabs.css', + 'css/components/tour.theme.css' => $this->root . '/core/themes/seven/css/components/tour.theme.css', ++ 'css/components/update-status.css' => $this->root . '/core/themes/seven/css/components/update-status.css', ++ 'css/components/views-ui.css' => $this->root . '/core/themes/seven/css/components/views-ui.css', ++ 'css/layout/layout.css' => $this->root . '/core/themes/seven/css/layout/layout.css', ++ 'css/layout/node-add.css' => $this->root . '/core/themes/seven/css/layout/node-add.css', ++ 'css/theme/appearance-page.css' => $this->root . '/core/themes/seven/css/theme/appearance-page.css', ), ), $info->info['stylesheets']); - $this->assertEquals(DRUPAL_ROOT . '/core/themes/seven/screenshot.png', $info->info['screenshot']); + $this->assertEquals($this->root . '/core/themes/seven/screenshot.png', $info->info['screenshot']); } /** diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 19797d9..9810aea 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -157,7 +157,7 @@ public static function hasService($id) { * @return string */ public static function root() { - return static::$container->get('app.root'); + return static::$container->getParameter('app.root'); } /** diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 5e8384b..f306305 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -179,6 +179,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { protected $sitePath; /** + * The app root. + * + * @var string + */ + protected $root; + + /** * Create a DrupalKernel object from a request. * * @param \Symfony\Component\HttpFoundation\Request $request @@ -238,6 +245,7 @@ public function __construct($environment, $class_loader, $allow_dumping = TRUE) $this->environment = $environment; $this->classLoader = $class_loader; $this->allowDumping = $allow_dumping; + $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); } /** @@ -351,22 +359,22 @@ public function boot() { Timer::start('page'); // Load legacy and other functional code. - require_once DRUPAL_ROOT . '/core/includes/common.inc'; - require_once DRUPAL_ROOT . '/core/includes/database.inc'; - require_once DRUPAL_ROOT . '/' . Settings::get('path_inc', 'core/includes/path.inc'); - require_once DRUPAL_ROOT . '/core/includes/module.inc'; - require_once DRUPAL_ROOT . '/core/includes/theme.inc'; - require_once DRUPAL_ROOT . '/core/includes/pager.inc'; - require_once DRUPAL_ROOT . '/' . Settings::get('menu_inc', 'core/includes/menu.inc'); - require_once DRUPAL_ROOT . '/core/includes/tablesort.inc'; - require_once DRUPAL_ROOT . '/core/includes/file.inc'; - require_once DRUPAL_ROOT . '/core/includes/unicode.inc'; - require_once DRUPAL_ROOT . '/core/includes/form.inc'; - require_once DRUPAL_ROOT . '/core/includes/mail.inc'; - require_once DRUPAL_ROOT . '/core/includes/ajax.inc'; - require_once DRUPAL_ROOT . '/core/includes/errors.inc'; - require_once DRUPAL_ROOT . '/core/includes/schema.inc'; - require_once DRUPAL_ROOT . '/core/includes/entity.inc'; + require_once $this->root . '/core/includes/common.inc'; + require_once $this->root . '/core/includes/database.inc'; + require_once $this->root . '/' . Settings::get('path_inc', 'core/includes/path.inc'); + require_once $this->root . '/core/includes/module.inc'; + require_once $this->root . '/core/includes/theme.inc'; + require_once $this->root . '/core/includes/pager.inc'; + require_once $this->root . '/' . Settings::get('menu_inc', 'core/includes/menu.inc'); + require_once $this->root . '/core/includes/tablesort.inc'; + require_once $this->root . '/core/includes/file.inc'; + require_once $this->root . '/core/includes/unicode.inc'; + require_once $this->root . '/core/includes/form.inc'; + require_once $this->root . '/core/includes/mail.inc'; + require_once $this->root . '/core/includes/ajax.inc'; + require_once $this->root . '/core/includes/errors.inc'; + require_once $this->root . '/core/includes/schema.inc'; + require_once $this->root . '/core/includes/entity.inc'; // Ensure that findSitePath is set. if (!$this->sitePath) { @@ -584,7 +592,7 @@ public function prepareLegacyRequest(Request $request) { protected function moduleData($module) { if (!$this->moduleData) { // First, find profiles. - $listing = new ExtensionDiscovery(DRUPAL_ROOT); + $listing = new ExtensionDiscovery($this->root); $listing->setProfileDirectories(array()); $all_profiles = $listing->scan('profile'); $profiles = array_intersect_key($all_profiles, $this->moduleList); @@ -985,7 +993,7 @@ protected function attachSynthetic(ContainerInterface $container) { // Set the class loader which was registered as a synthetic service. $container->set('class_loader', $this->classLoader); - $container->set('app.root', DRUPAL_ROOT); + $container->set('app.root', $this->root); return $container; } @@ -1012,7 +1020,7 @@ protected function compileContainer() { // Add all components in \Drupal\Core and \Drupal\Component that have a // Plugin directory. foreach (array('Core', 'Component') as $parent_directory) { - $path = DRUPAL_ROOT . '/core/lib/Drupal/' . $parent_directory; + $path = $this->root . '/core/lib/Drupal/' . $parent_directory; $parent_namespace = 'Drupal\\' . $parent_directory; foreach (new \DirectoryIterator($path) as $component) { if (!$component->isDot() && $component->isDir() && is_dir($component->getPathname() . '/Plugin')) { @@ -1219,7 +1227,7 @@ protected function getModuleFileNames() { protected function getModuleNamespacesPsr4($module_file_names) { $namespaces = array(); foreach ($module_file_names as $module => $filename) { - $namespaces["Drupal\\$module"] = DRUPAL_ROOT . '/' . dirname($filename) . '/src'; + $namespaces["Drupal\\$module"] = $this->root . '/' . dirname($filename) . '/src'; } return $namespaces; } diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index 6d92f98..4f59e1f 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -323,7 +323,7 @@ public function getLangcodes() { if (empty($langcodes)) { $langcodes = array(); // Collect languages included with CKEditor based on file listing. - $ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js'); + $ckeditor_languages = new \GlobIterator(\Drupal::root() . '/core/assets/vendor/ckeditor/lang/*.js'); foreach ($ckeditor_languages as $language_file) { $langcode = $language_file->getBasename('.js'); $langcodes[$langcode] = $langcode; diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 7010ddf..aa9ff40 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -118,7 +118,7 @@ function color_get_info($theme) { } $path = drupal_get_path('theme', $theme); - $file = DRUPAL_ROOT . '/' . $path . '/color/color.inc'; + $file = \Drupal::root() . '/' . $path . '/color/color.inc'; if ($path && file_exists($file)) { include $file; // Add in default values. diff --git a/core/modules/config/tests/config_test/src/TestInstallStorage.php b/core/modules/config/tests/config_test/src/TestInstallStorage.php index a689efc..e4b3864 100644 --- a/core/modules/config/tests/config_test/src/TestInstallStorage.php +++ b/core/modules/config/tests/config_test/src/TestInstallStorage.php @@ -25,7 +25,7 @@ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getComponentNames('core', array('core')); // @todo Refactor getComponentNames() to use the extension list directly. - $listing = new ExtensionDiscovery(DRUPAL_ROOT); + $listing = new ExtensionDiscovery(\Drupal::root()); $listing->setProfileDirectories(array()); $this->folders += $this->getComponentNames('profile', array_keys($listing->scan('profile'))); $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module'))); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 3fa834b..3d7c059 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -1160,7 +1160,7 @@ function _filter_html_image_secure_process($text) { $base_path_length = drupal_strlen($base_path); // Find the directory on the server where index.php resides. - $local_dir = DRUPAL_ROOT . '/'; + $local_dir = \Drupal::root() . '/'; $html_dom = Html::load($text); $images = $html_dom->getElementsByTagName('img'); diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php index d758615..717576a 100644 --- a/core/modules/image/src/Tests/ImageItemTest.php +++ b/core/modules/image/src/Tests/ImageItemTest.php @@ -55,7 +55,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(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg'); $this->image = entity_create('file', array( 'uri' => 'public://example.jpg', )); @@ -88,7 +88,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/feed.png', 'public://example-2.jpg'); + file_unmanaged_copy(\Drupal::root() . '/core/misc/feed.png', 'public://example-2.jpg'); $image2 = entity_create('file', array( 'uri' => 'public://example-2.jpg', )); diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php index 97c5a2b..9192e2b 100644 --- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php @@ -50,7 +50,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(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg'); $this->image = entity_create('file', array( 'uri' => 'public://example.jpg', )); diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php index 2b297a4..911fb03 100644 --- a/core/modules/rdf/src/Tests/StandardProfileTest.php +++ b/core/modules/rdf/src/Tests/StandardProfileTest.php @@ -131,7 +131,7 @@ protected function setUp() { $this->term->save(); // Create image. - file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg'); + file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg'); $this->image = entity_create('file', array('uri' => 'public://example.jpg')); $this->image->save(); diff --git a/core/modules/search/src/Tests/SearchSimplifyTest.php b/core/modules/search/src/Tests/SearchSimplifyTest.php index a850750..c3f7123 100644 --- a/core/modules/search/src/Tests/SearchSimplifyTest.php +++ b/core/modules/search/src/Tests/SearchSimplifyTest.php @@ -24,7 +24,7 @@ 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(\Drupal::root() . '/core/modules/search/tests/UnicodeTest.txt'); $basestrings = explode(chr(10), $input); $strings = array(); foreach ($basestrings as $key => $string) { diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install index 0094e53..147f4da 100644 --- a/core/modules/simpletest/simpletest.install +++ b/core/modules/simpletest/simpletest.install @@ -66,17 +66,17 @@ function simpletest_requirements($phase) { } $site_directory = 'sites/simpletest'; - if (!drupal_verify_install_file(DRUPAL_ROOT . '/' . $site_directory, FILE_EXIST|FILE_READABLE|FILE_WRITABLE|FILE_EXECUTABLE, 'dir')) { + if (!drupal_verify_install_file(\Drupal::root() . '/' . $site_directory, FILE_EXIST|FILE_READABLE|FILE_WRITABLE|FILE_EXECUTABLE, 'dir')) { $requirements['simpletest_site_directory'] = array( 'title' => t('Simpletest site directory'), - 'value' => is_dir(DRUPAL_ROOT . '/' . $site_directory) ? t('Not writable') : t('Missing'), + 'value' => is_dir(\Drupal::root() . '/' . $site_directory) ? t('Not writable') : t('Missing'), 'severity' => REQUIREMENT_ERROR, 'description' => t('The testing framework requires the !sites-simpletest directory to exist and be writable in order to run tests.', array( '!sites-simpletest' => './' . String::checkPlain($site_directory) . '', )), ); } - elseif (!file_save_htaccess(DRUPAL_ROOT . '/' . $site_directory, FALSE)) { + elseif (!file_save_htaccess(\Drupal::root() . '/' . $site_directory, FALSE)) { $requirements['simpletest_site_directory'] = array( 'title' => t('Simpletest site directory'), 'value' => t('Not protected'), diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 24665c7..01eab47 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -235,7 +235,7 @@ function simpletest_phpunit_xml_filepath($test_id) { * The path to core's phpunit.xml.dist configuration file. */ function simpletest_phpunit_configuration_filepath() { - return DRUPAL_ROOT . '/core/phpunit.xml.dist'; + return \Drupal::root() . '/core/phpunit.xml.dist'; } /** @@ -280,7 +280,7 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun // Need to change directories before running the command so that we can use // relative paths in the configuration file's exclusions. $old_cwd = getcwd(); - chdir(DRUPAL_ROOT . "/core"); + chdir(\Drupal::root() . "/core"); // exec in a subshell so that the environment is isolated when running tests // via the simpletest UI. @@ -301,10 +301,10 @@ function simpletest_phpunit_command() { if (substr(PHP_OS, 0, 3) == 'WIN') { $php_executable_finder = new PhpExecutableFinder(); $php = $php_executable_finder->find(); - $phpunit_bin = escapeshellarg($php) . " -f " . escapeshellarg(DRUPAL_ROOT . "/core/vendor/phpunit/phpunit/composer/bin/phpunit") . " --"; + $phpunit_bin = escapeshellarg($php) . " -f " . escapeshellarg(\Drupal::root() . "/core/vendor/phpunit/phpunit/composer/bin/phpunit") . " --"; } else { - $phpunit_bin = DRUPAL_ROOT . "/core/vendor/bin/phpunit"; + $phpunit_bin = \Drupal::root() . "/core/vendor/bin/phpunit"; } return $phpunit_bin; } diff --git a/core/modules/system/src/Tests/Ajax/FormValuesTest.php b/core/modules/system/src/Tests/Ajax/FormValuesTest.php index c4f1a7c..17e74f6 100644 --- a/core/modules/system/src/Tests/Ajax/FormValuesTest.php +++ b/core/modules/system/src/Tests/Ajax/FormValuesTest.php @@ -59,6 +59,6 @@ function testSimpleAjaxFormValue() { } // 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(\Drupal::root() . '/' . $this->siteDirectory . '/error.log'); } } diff --git a/core/modules/system/src/Tests/Common/SystemListingTest.php b/core/modules/system/src/Tests/Common/SystemListingTest.php index de6a941..6b2e1bb 100644 --- a/core/modules/system/src/Tests/Common/SystemListingTest.php +++ b/core/modules/system/src/Tests/Common/SystemListingTest.php @@ -37,7 +37,7 @@ 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.', array('@filename' => $filename))); + $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename))); } } diff --git a/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php index a7ac85a..ae93539 100644 --- a/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/src/Tests/DrupalKernel/DrupalKernelTest.php @@ -30,7 +30,7 @@ protected function setUp() { $this->settingsSet('php_storage', array('service_container' => array( 'bin' => 'service_container', 'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage', - 'directory' => DRUPAL_ROOT . '/' . $this->public_files_directory . '/php', + 'directory' => \Drupal::root() . '/' . $this->public_files_directory . '/php', 'secret' => Settings::getHashSalt(), ))); } @@ -52,7 +52,7 @@ protected function setUp() { */ protected function getTestKernel(Request $request, array $modules_enabled = NULL, $read_only = FALSE) { // Manually create kernel to avoid replacing settings. - $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; + $class_loader = require \Drupal::root() . '/core/vendor/autoload.php'; $kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing'); $this->settingsSet('hash_salt', $this->databasePrefix); if (isset($modules_enabled)) { diff --git a/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php b/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php index ef7a43a..07ce6ad 100644 --- a/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php +++ b/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php @@ -25,7 +25,7 @@ class FileTransferTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->testConnection = TestFileTransfer::factory(DRUPAL_ROOT, array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port)); + $this->testConnection = TestFileTransfer::factory(\Drupal::root(), array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port)); } function _getFakeModuleFiles() { @@ -87,7 +87,7 @@ function testJail() { $gotit = TRUE; try { - $this->testConnection->copyDirectory($source, DRUPAL_ROOT . '/' . PublicStream::basePath()); + $this->testConnection->copyDirectory($source, \Drupal::root() . '/' . PublicStream::basePath()); } catch (FileTransferException $e) { $gotit = FALSE; diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php index cd7bce5..0c183d8 100644 --- a/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerLanguageDirectionTest.php @@ -28,8 +28,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(\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\""); parent::setUpLanguage(); // After selecting a different language than English, all following screens diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php index 4c74ddc..ce573ba 100644 --- a/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php @@ -21,8 +21,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(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); + touch(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.xoxo.po'); // Check that all predefined languages show up with their native names. $this->drupalGet($GLOBALS['base_url'] . '/core/install.php'); diff --git a/core/modules/system/src/Tests/Installer/InstallerTest.php b/core/modules/system/src/Tests/Installer/InstallerTest.php index 760a942..6d48123 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTest.php @@ -26,7 +26,7 @@ public function testInstaller() { $this->assertText($this->root_user->getUsername()); // Verify that the confirmation message appears. - require_once DRUPAL_ROOT . '/core/includes/install.inc'; + require_once \Drupal::root() . '/core/includes/install.inc'; $this->assertRaw(t('Congratulations, you installed @drupal!', array( '@drupal' => drupal_install_profile_distribution_name(), ))); diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php index 1ab8e5a..3ce8361 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php @@ -29,8 +29,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', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue German\""); + mkdir(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE); + file_put_contents(\Drupal::root() . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue German\""); parent::setUpLanguage(); // After selecting a different language than English, all following screens diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php index 031a79d..844ff83 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php @@ -19,7 +19,7 @@ class InstallerTranslationVersionUnitTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; + require_once \Drupal::root() . '/core/includes/install.core.inc'; } /** diff --git a/core/modules/system/src/Tests/PhpStorage/PhpStorageFactoryTest.php b/core/modules/system/src/Tests/PhpStorage/PhpStorageFactoryTest.php index 166f3ff..bad4c2f 100644 --- a/core/modules/system/src/Tests/PhpStorage/PhpStorageFactoryTest.php +++ b/core/modules/system/src/Tests/PhpStorage/PhpStorageFactoryTest.php @@ -59,7 +59,7 @@ public function testGetOverride() { $this->setSettings('test', array('directory' => NULL)); $php = PhpStorageFactory::get('test'); $this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.'); - $this->assertIdentical(DRUPAL_ROOT . '/' . PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.'); + $this->assertIdentical(\Drupal::root() . '/' . PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.'); // Test that a default storage class is set if it's empty. $this->setSettings('test', array('class' => NULL)); diff --git a/core/modules/system/src/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/modules/system/src/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php index 941a93a..05d5a43 100644 --- a/core/modules/system/src/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php +++ b/core/modules/system/src/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php @@ -52,7 +52,7 @@ protected function setUp() { ), ); - $base_directory = DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/src'; + $base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src'; $namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory)); $this->discovery = new AnnotatedClassDiscovery('Plugin/plugin_test/fruit', $namespaces); diff --git a/core/modules/system/src/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php b/core/modules/system/src/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php index eb5285e..890329c 100644 --- a/core/modules/system/src/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php +++ b/core/modules/system/src/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php @@ -35,7 +35,7 @@ protected function setUp() { ), ); - $base_directory = DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/src'; + $base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src'; $root_namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory)); $this->discovery = new AnnotatedClassDiscovery('Plugin/plugin_test/custom_annotation', $root_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); diff --git a/core/modules/system/src/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php b/core/modules/system/src/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php index aa29a09..ad6f5e4 100644 --- a/core/modules/system/src/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php +++ b/core/modules/system/src/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php @@ -66,7 +66,7 @@ protected function setUp() { ), ); - $base_directory = DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/src'; + $base_directory = \Drupal::root() . '/core/modules/system/tests/modules/plugin_test/src'; $namespaces = new \ArrayObject(array('Drupal\plugin_test' => $base_directory)); $this->discovery = new AnnotatedClassDiscovery('', $namespaces); diff --git a/core/modules/system/src/Tests/System/ErrorHandlerTest.php b/core/modules/system/src/Tests/System/ErrorHandlerTest.php index 69f1760..30a77b8 100644 --- a/core/modules/system/src/Tests/System/ErrorHandlerTest.php +++ b/core/modules/system/src/Tests/System/ErrorHandlerTest.php @@ -121,7 +121,7 @@ function testExceptionHandler() { // 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(\Drupal::root() . '/' . $this->siteDirectory . '/error.log'); } /** diff --git a/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php index f9ceb3a..3615c43 100644 --- a/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php +++ b/core/modules/system/src/Tests/System/IgnoreReplicaSubscriberTest.php @@ -32,7 +32,7 @@ function testSystemInitIgnoresSecondaries() { Database::addConnectionInfo('default', 'replica', $connection_info['default']); db_ignore_replica(); - $class_loader = require DRUPAL_ROOT . '/core/vendor/autoload.php'; + $class_loader = require \Drupal::root() . '/core/vendor/autoload.php'; $kernel = new DrupalKernel('testing', $class_loader, FALSE); $event = new GetResponseEvent($kernel, Request::create('http://example.com'), HttpKernelInterface::MASTER_REQUEST); $subscriber = new ReplicaDatabaseIgnoreSubscriber(); diff --git a/core/modules/system/src/Tests/System/SettingsRewriteTest.php b/core/modules/system/src/Tests/System/SettingsRewriteTest.php index 741f92c..70b4043 100644 --- a/core/modules/system/src/Tests/System/SettingsRewriteTest.php +++ b/core/modules/system/src/Tests/System/SettingsRewriteTest.php @@ -20,7 +20,7 @@ class SettingsRewriteTest extends KernelTestBase { * Tests the drupal_rewrite_settings() function. */ function testDrupalRewriteSettings() { - include_once DRUPAL_ROOT . '/core/includes/install.inc'; + include_once \Drupal::root() . '/core/includes/install.inc'; $tests = array( array( 'original' => '$no_index_value_scalar = TRUE;', @@ -100,9 +100,9 @@ function testDrupalRewriteSettings() { ); foreach ($tests as $test) { $filename = Settings::get('file_public_path', conf_path() . '/files') . '/mock_settings.php'; - file_put_contents(DRUPAL_ROOT . '/' . $filename, "assertEqual(file_get_contents(DRUPAL_ROOT . '/' . $filename), "assertEqual(file_get_contents(\Drupal::root() . '/' . $filename), "assertEqual(file_get_contents(DRUPAL_ROOT . '/' . $filename), "assertEqual(file_get_contents(\Drupal::root() . '/' . $filename), "siteDirectory . '/error.log'); + unlink(\Drupal::root() . '/' . $this->siteDirectory . '/error.log'); parent::tearDown(); } diff --git a/core/modules/system/src/Tests/TypedData/TypedDataTest.php b/core/modules/system/src/Tests/TypedData/TypedDataTest.php index 4185c17..e1dcc4d 100644 --- a/core/modules/system/src/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/src/Tests/TypedData/TypedDataTest.php @@ -244,7 +244,7 @@ public function testGetAndSet() { $files = array(); for ($i = 0; $i < 3; $i++){ $path = "public://example_$i.png"; - file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', $path); + file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path); $image = entity_create('file', array('uri' => $path)); $image->save(); $files[] = $image; diff --git a/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php b/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php index f75190a..1dd0bef 100644 --- a/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php +++ b/core/modules/system/src/Tests/Update/DependencyHookInvocationTest.php @@ -26,7 +26,7 @@ class DependencyHookInvocationTest extends WebTestBase { protected function setUp() { parent::setUp(); - require_once DRUPAL_ROOT . '/core/includes/update.inc'; + require_once \Drupal::root() . '/core/includes/update.inc'; } /** diff --git a/core/modules/system/src/Tests/Update/DependencyMissingTest.php b/core/modules/system/src/Tests/Update/DependencyMissingTest.php index 7c31851..70cd56b 100644 --- a/core/modules/system/src/Tests/Update/DependencyMissingTest.php +++ b/core/modules/system/src/Tests/Update/DependencyMissingTest.php @@ -27,7 +27,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 \Drupal::root() . '/core/includes/update.inc'; } function testMissingUpdate() { diff --git a/core/modules/system/src/Tests/Update/DependencyOrderingTest.php b/core/modules/system/src/Tests/Update/DependencyOrderingTest.php index 4bf270a..1360c6d 100644 --- a/core/modules/system/src/Tests/Update/DependencyOrderingTest.php +++ b/core/modules/system/src/Tests/Update/DependencyOrderingTest.php @@ -25,7 +25,7 @@ class DependencyOrderingTest extends WebTestBase { protected function setUp() { parent::setUp(); - require_once DRUPAL_ROOT . '/core/includes/update.inc'; + require_once \Drupal::root() . '/core/includes/update.inc'; } /** diff --git a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php index b5ea8fc..228d62c 100644 --- a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php +++ b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php @@ -41,7 +41,7 @@ class InvalidUpdateHookTest extends WebTestBase { protected function setUp() { parent::setUp(); - require_once DRUPAL_ROOT . '/core/includes/update.inc'; + require_once \Drupal::root() . '/core/includes/update.inc'; $this->update_url = $GLOBALS['base_url'] . '/update.php'; $this->update_user = $this->drupalCreateUser(array('administer software updates')); diff --git a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php index b6c215d..09daad3 100644 --- a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php +++ b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php @@ -36,7 +36,7 @@ class UpdatesWith7xTest extends WebTestBase { protected function setUp() { parent::setUp(); - require_once DRUPAL_ROOT . '/core/includes/update.inc'; + require_once \Drupal::root() . '/core/includes/update.inc'; $this->update_url = $GLOBALS['base_url'] . '/update.php'; $this->update_user = $this->drupalCreateUser(array('administer software updates')); } diff --git a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php index 6d98ebd..05c4709 100644 --- a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php +++ b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php @@ -36,7 +36,7 @@ protected function setUp() { $this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); - $theme = new Extension('theme', DRUPAL_ROOT . '/core/themes/bartik', 'bartik.info.yml'); + $theme = new Extension(\Drupal::root(), 'theme', '/core/themes/bartik', 'bartik.info.yml'); $theme->status = 1; $theme->info = array('name' => 'bartik'); $this->themeHandler->expects($this->any()) diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index 03201ab..bc70e63 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -189,7 +189,7 @@ function testUninstallReinstall() { ); entity_create('field_instance_config', $instance_definition)->save(); - require_once DRUPAL_ROOT . '/core/includes/install.inc'; + require_once \Drupal::root() . '/core/includes/install.inc'; $this->container->get('module_handler')->uninstall(array('taxonomy')); \Drupal::moduleHandler()->install(array('taxonomy')); diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index 3198a28..e65e730 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -207,7 +207,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // update_authorize_run_install() directly. if (fileowner($project_real_location) == fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); - $filetransfer = new Local(DRUPAL_ROOT); + $filetransfer = new Local(\drupal::root()); call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments)); } diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 66e94de..6c7c108 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -133,7 +133,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // and invoke update_authorize_run_update() directly. if (fileowner($project_real_location) == fileowner(conf_path())) { $this->moduleHandler->loadInclude('update', 'inc', 'update.authorize'); - $filetransfer = new Local(DRUPAL_ROOT); + $filetransfer = new Local(\Drupal::root()); update_authorize_run_update($filetransfer, $updates); } // Otherwise, go through the regular workflow to prompt for FTP/SSH diff --git a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php index 492218f..188da36 100644 --- a/core/modules/user/src/Tests/UserAccountFormFieldsTest.php +++ b/core/modules/user/src/Tests/UserAccountFormFieldsTest.php @@ -29,8 +29,8 @@ class UserAccountFormFieldsTest extends DrupalUnitTestBase { * Tests the root user account form section in the "Configure site" form. */ function testInstallConfigureForm() { - require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; - require_once DRUPAL_ROOT . '/core/includes/install.inc'; + require_once \Drupal::root() . '/core/includes/install.core.inc'; + require_once \Drupal::root() . '/core/includes/install.inc'; $install_state = install_state_defaults(); $form_state = new FormState(); $form_state['build_info']['args'][] = &$install_state; diff --git a/core/modules/views/views.module b/core/modules/views/views.module index b4da2d9..2b5c009 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -188,7 +188,7 @@ function views_theme($existing, $type, $theme, $path) { // Whenever we got a theme file, we include it directly so we can // auto-detect the theme function. if (isset($def['theme_file'])) { - $include = DRUPAL_ROOT . '/' . $module_dir. '/' . $def['theme_file']; + $include = \Drupal::root() . '/' . $module_dir. '/' . $def['theme_file']; if (is_file($include)) { require_once $include; } diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php index d4a9fe4..70bc427 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php @@ -31,6 +31,13 @@ class LibraryDiscoveryParserTest extends UnitTestCase { /** + * The app root. + * + * @var string + */ + protected $root; + + /** * The tested library provider. * * @var \Drupal\Core\Asset\LibraryDiscoveryParser|\Drupal\Tests\Core\Asset\TestLibraryDiscoveryParser @@ -63,8 +70,8 @@ class LibraryDiscoveryParserTest extends UnitTestCase { */ protected function setUp() { $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); - $root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); - $this->libraryDiscoveryParser = new TestLibraryDiscoveryParser($root, $this->moduleHandler); + $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); + $this->libraryDiscoveryParser = new TestLibraryDiscoveryParser($this->root, $this->moduleHandler); } /** @@ -79,7 +86,7 @@ public function testBuildByExtensionSimple() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'example_module', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('example_module', 'example'); @@ -106,7 +113,7 @@ public function testBuildByExtensionWithTheme() { ->will($this->returnValue(FALSE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('theme', 'example_theme', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('example_theme'); @@ -130,7 +137,7 @@ public function testBuildByExtensionWithMissingLibraryFile() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files_not_existing'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'example_module', $path); $this->assertSame($this->libraryDiscoveryParser->buildByExtension('example_module'), array()); @@ -150,7 +157,7 @@ public function testInvalidLibrariesFile() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'invalid_file', $path); $this->libraryDiscoveryParser->buildByExtension('invalid_file'); @@ -171,7 +178,7 @@ public function testBuildByExtensionWithMissingInformation() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'example_module_missing_information', $path); $this->libraryDiscoveryParser->buildByExtension('example_module_missing_information'); @@ -189,7 +196,7 @@ public function testExternalLibraries() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'external', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('external', 'example_external'); @@ -211,7 +218,7 @@ public function testDefaultCssWeights() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'css_weights', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('css_weights'); @@ -251,7 +258,7 @@ public function testJsWithPositiveWeight() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'js_positive_weight', $path); $this->libraryDiscoveryParser->buildByExtension('js_positive_weight'); @@ -269,7 +276,7 @@ public function testLibraryWithCssJsSetting() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'css_js_settings', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('css_js_settings'); @@ -300,7 +307,7 @@ public function testLibraryWithDependencies() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'dependencies', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('dependencies'); @@ -323,7 +330,7 @@ public function testLibraryWithDataTypes() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'data_types', $path); $this->libraryDiscoveryParser->setFileValidUri('public://test.css', TRUE); @@ -355,7 +362,7 @@ public function testLibraryWithJavaScript() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'js', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('js'); @@ -380,7 +387,7 @@ public function testLibraryThirdPartyWithMissingLicense() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'licenses_missing_information', $path); $this->libraryDiscoveryParser->buildByExtension('licenses_missing_information'); @@ -398,7 +405,7 @@ public function testLibraryWithLicenses() { ->will($this->returnValue(TRUE)); $path = __DIR__ . '/library_test_files'; - $path = substr($path, strlen(DRUPAL_ROOT) + 1); + $path = substr($path, strlen($this->root) + 1); $this->libraryDiscoveryParser->setPaths('module', 'licenses', $path); $libraries = $this->libraryDiscoveryParser->buildByExtension('licenses'); diff --git a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php index b1c1c8b..666547b 100644 --- a/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/DefaultConfigTest.php @@ -28,7 +28,8 @@ class DefaultConfigTest extends UnitTestCase { * would not exist. Installation hooks would never be executed. */ public function testConfigIsEmpty() { - $config = Yaml::parse(file_get_contents(DRUPAL_ROOT . '/core/config/install/core.extension.yml')); + $root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); + $config = Yaml::parse(file_get_contents($root . '/core/config/install/core.extension.yml')); $expected = array( 'module' => array(), 'theme' => array(), diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php index 73d81ab..2f0a67a 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php @@ -515,6 +515,7 @@ public function dependencyProvider() { public function testGetModuleDirectories() { $this->moduleHandler->setModuleList(array()); $this->moduleHandler->addModule('module', 'place'); - $this->assertEquals(array('module' => DRUPAL_ROOT . '/place'), $this->moduleHandler->getModuleDirectories()); + $root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); + $this->assertEquals(array('module' => $root . '/place'), $this->moduleHandler->getModuleDirectories()); } } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php index 8470a6f..81f290b 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php @@ -50,6 +50,7 @@ protected function setUp() { $container = new ContainerBuilder(); $config_factory = $this->getConfigFactoryStub(array()); $container->set('config.factory', $config_factory); + $container->setParameter('app.root', dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))); \Drupal::setContainer($container); $this->container = $container; } @@ -142,7 +143,7 @@ protected function assertLocalTasks($route_name, $expected_tasks, $route_params $directory_list = array(); foreach ($this->directoryList as $key => $value) { - $directory_list[$key] = DRUPAL_ROOT . '/' . $value; + $directory_list[$key] = \Drupal::root() . '/' . $value; } $manager = $this->getLocalTaskManager($directory_list, $route_name, $route_params); diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index 1eb0d26..34a890b 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -53,7 +53,8 @@ protected function setUp() { ); $this->namespaces = new \ArrayObject(); - $this->namespaces['Drupal\plugin_test'] = DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/src'; + $root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); + $this->namespaces['Drupal\plugin_test'] = $root . '/core/modules/system/tests/modules/plugin_test/src'; } /** diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index c6c3576..00ec88d 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -73,7 +73,8 @@ public function testGetRegistryForModule() { $this->registry->setBaseThemes(array()); // Include the module so that hook_theme can be called. - include_once DRUPAL_ROOT . '/core/modules/system/tests/modules/theme_test/theme_test.module'; + $root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)))); + include_once $root . '/core/modules/system/tests/modules/theme_test/theme_test.module'; $this->moduleHandler->expects($this->once()) ->method('getImplementations') ->with('theme') diff --git a/core/themes/engines/phptemplate/phptemplate.engine b/core/themes/engines/phptemplate/phptemplate.engine index 0521092..636da47 100644 --- a/core/themes/engines/phptemplate/phptemplate.engine +++ b/core/themes/engines/phptemplate/phptemplate.engine @@ -49,7 +49,7 @@ function phptemplate_render_template($template_file, $variables) { ob_start(); // Include the template file - include DRUPAL_ROOT . '/' . $template_file; + include \Drupal::root() . '/' . $template_file; // End buffering and return its contents return ob_get_clean();