Skip to content
Snippets Groups Projects
Commit 6a33f3c6 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3258667 by phenaproxima: PathLocator::getActiveDirectory() is redundant

parent 40640aea
No related branches found
No related tags found
No related merge requests found
Showing
with 12 additions and 26 deletions
...@@ -26,16 +26,6 @@ class PathLocator { ...@@ -26,16 +26,6 @@ class PathLocator {
$this->appRoot = $app_root; $this->appRoot = $app_root;
} }
/**
* Returns the path of the active code base.
*
* @return string
* The absolute path of the active, running code base.
*/
public function getActiveDirectory(): string {
return $this->getProjectRoot();
}
/** /**
* Returns the absolute path of the project root. * Returns the absolute path of the project root.
* *
......
...@@ -219,7 +219,7 @@ class Stage { ...@@ -219,7 +219,7 @@ class Stage {
$this->tempStore->set(static::TEMPSTORE_LOCK_KEY, [$id, static::class]); $this->tempStore->set(static::TEMPSTORE_LOCK_KEY, [$id, static::class]);
$this->claim($id); $this->claim($id);
$active_dir = $this->pathLocator->getActiveDirectory(); $active_dir = $this->pathLocator->getProjectRoot();
$stage_dir = $this->getStageDirectory(); $stage_dir = $this->getStageDirectory();
$event = new PreCreateEvent($this); $event = new PreCreateEvent($this);
...@@ -262,7 +262,7 @@ class Stage { ...@@ -262,7 +262,7 @@ class Stage {
public function apply(): void { public function apply(): void {
$this->checkOwnership(); $this->checkOwnership();
$active_dir = $this->pathLocator->getActiveDirectory(); $active_dir = $this->pathLocator->getProjectRoot();
$stage_dir = $this->getStageDirectory(); $stage_dir = $this->getStageDirectory();
$event = new PreApplyEvent($this); $event = new PreApplyEvent($this);
...@@ -363,7 +363,7 @@ class Stage { ...@@ -363,7 +363,7 @@ class Stage {
* The Composer utility object. * The Composer utility object.
*/ */
public function getActiveComposer(): ComposerUtility { public function getActiveComposer(): ComposerUtility {
$dir = $this->pathLocator->getActiveDirectory(); $dir = $this->pathLocator->getProjectRoot();
return ComposerUtility::createForDirectory($dir); return ComposerUtility::createForDirectory($dir);
} }
......
...@@ -64,7 +64,7 @@ class LockFileValidator implements PreOperationStageValidatorInterface { ...@@ -64,7 +64,7 @@ class LockFileValidator implements PreOperationStageValidatorInterface {
* does not exist. * does not exist.
*/ */
protected function getHash() { protected function getHash() {
$file = $this->pathLocator->getActiveDirectory() . DIRECTORY_SEPARATOR . 'composer.lock'; $file = $this->pathLocator->getProjectRoot() . DIRECTORY_SEPARATOR . 'composer.lock';
// We want to directly hash the lock file itself, rather than look at its // We want to directly hash the lock file itself, rather than look at its
// content-hash value, which is actually a hash of the relevant parts of // content-hash value, which is actually a hash of the relevant parts of
// composer.json. We're trying to verify that the actual installed packages // composer.json. We're trying to verify that the actual installed packages
......
...@@ -61,7 +61,7 @@ class ComposerSettingsValidatorTest extends PackageManagerKernelTestBase { ...@@ -61,7 +61,7 @@ class ComposerSettingsValidatorTest extends PackageManagerKernelTestBase {
public function testSecureHttpValidation(string $contents, array $expected_results): void { public function testSecureHttpValidation(string $contents, array $expected_results): void {
$this->createTestProject(); $this->createTestProject();
$active_dir = $this->container->get('package_manager.path_locator') $active_dir = $this->container->get('package_manager.path_locator')
->getActiveDirectory(); ->getProjectRoot();
file_put_contents("$active_dir/composer.json", $contents); file_put_contents("$active_dir/composer.json", $contents);
try { try {
......
...@@ -42,7 +42,7 @@ class ExcludedPathsTest extends PackageManagerKernelTestBase { ...@@ -42,7 +42,7 @@ class ExcludedPathsTest extends PackageManagerKernelTestBase {
$this->createTestProject(); $this->createTestProject();
$active_dir = $this->container->get('package_manager.path_locator') $active_dir = $this->container->get('package_manager.path_locator')
->getActiveDirectory(); ->getProjectRoot();
$site_path = 'sites/example.com'; $site_path = 'sites/example.com';
// Ensure that we are using directories within the fake site fixture for // Ensure that we are using directories within the fake site fixture for
...@@ -199,7 +199,7 @@ class ExcludedPathsTest extends PackageManagerKernelTestBase { ...@@ -199,7 +199,7 @@ class ExcludedPathsTest extends PackageManagerKernelTestBase {
public function testUnreadableDirectoriesAreIgnored(): void { public function testUnreadableDirectoriesAreIgnored(): void {
$this->createTestProject(); $this->createTestProject();
$active_dir = $this->container->get('package_manager.path_locator') $active_dir = $this->container->get('package_manager.path_locator')
->getActiveDirectory(); ->getProjectRoot();
// Create an unreadable directory within the active directory, which will // Create an unreadable directory within the active directory, which will
// raise an exception as the event subscriber tries to scan for .git // raise an exception as the event subscriber tries to scan for .git
......
...@@ -29,7 +29,7 @@ class LockFileValidatorTest extends PackageManagerKernelTestBase { ...@@ -29,7 +29,7 @@ class LockFileValidatorTest extends PackageManagerKernelTestBase {
parent::setUp(); parent::setUp();
$this->createTestProject(); $this->createTestProject();
$this->activeDir = $this->container->get('package_manager.path_locator') $this->activeDir = $this->container->get('package_manager.path_locator')
->getActiveDirectory(); ->getProjectRoot();
} }
/** /**
......
...@@ -218,7 +218,6 @@ END, ...@@ -218,7 +218,6 @@ END,
TestStage::$stagingRoot = "$root/stage"; TestStage::$stagingRoot = "$root/stage";
$path_locator = $this->prophesize(PathLocator::class); $path_locator = $this->prophesize(PathLocator::class);
$path_locator->getActiveDirectory()->willReturn($active_dir);
$path_locator->getProjectRoot()->willReturn($active_dir); $path_locator->getProjectRoot()->willReturn($active_dir);
$path_locator->getWebRoot()->willReturn(''); $path_locator->getWebRoot()->willReturn('');
$path_locator->getVendorDirectory()->willReturn("$active_dir/vendor"); $path_locator->getVendorDirectory()->willReturn("$active_dir/vendor");
...@@ -238,7 +237,7 @@ END, ...@@ -238,7 +237,7 @@ END,
// By default, the validator should report that the root, vendor, and // By default, the validator should report that the root, vendor, and
// temporary directories have basically infinite free space. // temporary directories have basically infinite free space.
$validator->freeSpace = [ $validator->freeSpace = [
$path_locator->getActiveDirectory() => PHP_INT_MAX, $path_locator->getProjectRoot() => PHP_INT_MAX,
$path_locator->getVendorDirectory() => PHP_INT_MAX, $path_locator->getVendorDirectory() => PHP_INT_MAX,
$validator->temporaryDirectory() => PHP_INT_MAX, $validator->temporaryDirectory() => PHP_INT_MAX,
]; ];
......
...@@ -30,7 +30,7 @@ class Updater extends Stage { ...@@ -30,7 +30,7 @@ class Updater extends Stage {
throw new \InvalidArgumentException("Currently only updates to Drupal core are supported."); throw new \InvalidArgumentException("Currently only updates to Drupal core are supported.");
} }
$composer = ComposerUtility::createForDirectory($this->pathLocator->getActiveDirectory()); $composer = ComposerUtility::createForDirectory($this->pathLocator->getProjectRoot());
$package_versions = [ $package_versions = [
'production' => [], 'production' => [],
'dev' => [], 'dev' => [],
......
...@@ -89,7 +89,7 @@ class ReadinessValidationManager { ...@@ -89,7 +89,7 @@ class ReadinessValidationManager {
* @return $this * @return $this
*/ */
public function run(): self { public function run(): self {
$composer = ComposerUtility::createForDirectory($this->pathLocator->getActiveDirectory()); $composer = ComposerUtility::createForDirectory($this->pathLocator->getProjectRoot());
$recommender = new UpdateRecommender(); $recommender = new UpdateRecommender();
$release = $recommender->getRecommendedRelease(TRUE); $release = $recommender->getRecommendedRelease(TRUE);
......
...@@ -60,7 +60,7 @@ class StagedDatabaseUpdateValidator implements EventSubscriberInterface { ...@@ -60,7 +60,7 @@ class StagedDatabaseUpdateValidator implements EventSubscriberInterface {
return; return;
} }
$active_dir = $this->pathLocator->getActiveDirectory(); $active_dir = $this->pathLocator->getProjectRoot();
$stage_dir = $stage->getStageDirectory(); $stage_dir = $stage->getStageDirectory();
$web_root = $this->pathLocator->getWebRoot(); $web_root = $this->pathLocator->getWebRoot();
......
...@@ -28,7 +28,6 @@ class CoreComposerValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -28,7 +28,6 @@ class CoreComposerValidatorTest extends AutomaticUpdatesKernelTestBase {
// Point to a valid composer.json with no requirements. // Point to a valid composer.json with no requirements.
$active_dir = __DIR__ . '/../../../fixtures/project_staged_validation/no_core_requirements'; $active_dir = __DIR__ . '/../../../fixtures/project_staged_validation/no_core_requirements';
$locator = $this->prophesize(PathLocator::class); $locator = $this->prophesize(PathLocator::class);
$locator->getActiveDirectory()->willReturn($active_dir);
$locator->getProjectRoot()->willReturn($active_dir); $locator->getProjectRoot()->willReturn($active_dir);
$locator->getVendorDirectory()->willReturn($active_dir . '/vendor'); $locator->getVendorDirectory()->willReturn($active_dir . '/vendor');
$this->container->set('package_manager.path_locator', $locator->reveal()); $this->container->set('package_manager.path_locator', $locator->reveal());
......
...@@ -62,7 +62,6 @@ class StagedProjectsValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -62,7 +62,6 @@ class StagedProjectsValidatorTest extends AutomaticUpdatesKernelTestBase {
private function validate(string $active_dir, string $stage_dir): array { private function validate(string $active_dir, string $stage_dir): array {
$locator = $this->prophesize(PathLocator::class); $locator = $this->prophesize(PathLocator::class);
$locator->getActiveDirectory()->willReturn($active_dir);
$locator->getProjectRoot()->willReturn($active_dir); $locator->getProjectRoot()->willReturn($active_dir);
$locator->getWebRoot()->willReturn(''); $locator->getWebRoot()->willReturn('');
$locator->getVendorDirectory()->willReturn($active_dir); $locator->getVendorDirectory()->willReturn($active_dir);
......
...@@ -49,7 +49,6 @@ class UpdaterTest extends AutomaticUpdatesKernelTestBase { ...@@ -49,7 +49,6 @@ class UpdaterTest extends AutomaticUpdatesKernelTestBase {
// result in drupal/core-recommended being updated. // result in drupal/core-recommended being updated.
$fixture_dir = __DIR__ . '/../../fixtures/fake-site'; $fixture_dir = __DIR__ . '/../../fixtures/fake-site';
$locator = $this->prophesize(PathLocator::class); $locator = $this->prophesize(PathLocator::class);
$locator->getActiveDirectory()->willReturn($fixture_dir);
$locator->getProjectRoot()->willReturn($fixture_dir); $locator->getProjectRoot()->willReturn($fixture_dir);
$locator->getWebRoot()->willReturn(''); $locator->getWebRoot()->willReturn('');
$locator->getVendorDirectory()->willReturn($fixture_dir); $locator->getVendorDirectory()->willReturn($fixture_dir);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment