Chris@0: drupalKernel = $drupal_kernel; Chris@0: $this->requestStack = $request_stack; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the root path under which projects are installed or updated. Chris@0: * Chris@0: * The Update Manager will ensure that project files can only be copied to Chris@0: * specific subdirectories of this root path. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function get() { Chris@0: // Normally the Update Manager's root path is the same as the app root (the Chris@0: // directory in which the Drupal site is installed). Chris@0: $root_path = $this->drupalKernel->getAppRoot(); Chris@0: Chris@0: // When running in a test site, change the root path to be the testing site Chris@0: // directory. This ensures that it will always be writable by the webserver Chris@0: // (thereby allowing the actual extraction and installation of projects by Chris@0: // the Update Manager to be tested) and also ensures that new project files Chris@0: // added there won't be visible to the parent site and will be properly Chris@0: // cleaned up once the test finishes running. This is done here (rather Chris@0: // than having the tests enable a module which overrides the update root Chris@0: // factory service) to ensure that the parent site is automatically kept Chris@0: // clean without relying on test authors to take any explicit steps. See Chris@0: // also \Drupal\update\Tests\UpdateTestBase::setUp(). Chris@0: if (DRUPAL_TEST_IN_CHILD_SITE) { Chris@0: $kernel = $this->drupalKernel; Chris@0: $request = $this->requestStack->getCurrentRequest(); Chris@0: $root_path .= '/' . $kernel::findSitePath($request); Chris@0: } Chris@0: Chris@0: return $root_path; Chris@0: } Chris@0: Chris@0: }