diff --git a/src/Command/DeployCommand.php b/src/Command/DeployCommand.php index c15a2a2c..98f0156f 100755 --- a/src/Command/DeployCommand.php +++ b/src/Command/DeployCommand.php @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $configurationPath = $input->getOption('configurationPath'); $deploymentName = $input->getArgument('deploymentName'); - $deployment = $this->factory->getDeployment($deploymentName, $configurationPath, false, true, $input->getOption('force')); + $deployment = $this->factory->getDeployment((string)$deploymentName, $configurationPath, false, true, $input->getOption('force')); $deployment->deploy(); return $deployment->getStatus(); diff --git a/src/Command/DescribeCommand.php b/src/Command/DescribeCommand.php index 485729d9..8737f991 100755 --- a/src/Command/DescribeCommand.php +++ b/src/Command/DescribeCommand.php @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->output = $output; $configurationPath = $input->getOption('configurationPath'); $deploymentName = $input->getArgument('deploymentName'); - $deployment = $this->factory->getDeployment($deploymentName, $configurationPath); + $deployment = $this->factory->getDeployment((string)$deploymentName, $configurationPath); $workflow = $deployment->getWorkflow(); if (! $deployment instanceof FailedDeployment) { diff --git a/src/Command/RollbackCommand.php b/src/Command/RollbackCommand.php index 9dea6cd8..c275dece 100644 --- a/src/Command/RollbackCommand.php +++ b/src/Command/RollbackCommand.php @@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $configurationPath = $input->getOption('configurationPath'); $deploymentName = $input->getArgument('deploymentName'); - $deployment = $this->factory->getDeployment($deploymentName, $configurationPath, $input->getOption('simulate'), false); + $deployment = $this->factory->getDeployment((string)$deploymentName, $configurationPath, $input->getOption('simulate'), false); $deployment->rollback($input->getOption('simulate')); return $deployment->getStatus(); diff --git a/src/Command/SimulateCommand.php b/src/Command/SimulateCommand.php index b20f3446..882da54b 100755 --- a/src/Command/SimulateCommand.php +++ b/src/Command/SimulateCommand.php @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $configurationPath = $input->getOption('configurationPath'); $deploymentName = $input->getArgument('deploymentName'); - $deployment = $this->factory->getDeployment($deploymentName, $configurationPath, true, true, $input->getOption('force')); + $deployment = $this->factory->getDeployment((string)$deploymentName, $configurationPath, true, true, $input->getOption('force')); $deployment->simulate(); return $deployment->getStatus(); diff --git a/src/Domain/Filesystem/Filesystem.php b/src/Domain/Filesystem/Filesystem.php index af4ddad9..e65c2301 100644 --- a/src/Domain/Filesystem/Filesystem.php +++ b/src/Domain/Filesystem/Filesystem.php @@ -50,7 +50,7 @@ public function getRealPath(string $path): string $realpath = realpath($path); if ($realpath === false) { - throw new \InvalidArgumentException(sprintf('Could not create realpath from path %s', $path)); + return ''; } return $realpath; @@ -70,9 +70,4 @@ public function glob(string $pattern): array { return glob($pattern); } - - public function requireFile(string $file): void - { - require($file); - } } diff --git a/src/Domain/Filesystem/FilesystemInterface.php b/src/Domain/Filesystem/FilesystemInterface.php index df771544..9ecad873 100644 --- a/src/Domain/Filesystem/FilesystemInterface.php +++ b/src/Domain/Filesystem/FilesystemInterface.php @@ -39,6 +39,4 @@ public function fileExists(string $file): bool; public function createDirectory(string $directory): bool; public function glob(string $pattern): array; - - public function requireFile(string $file): void; } diff --git a/src/Integration/Factory.php b/src/Integration/Factory.php index db6a6c1a..a64492fd 100644 --- a/src/Integration/Factory.php +++ b/src/Integration/Factory.php @@ -196,7 +196,7 @@ protected function createDeployment(string $deploymentName, string $path = null) $this->ensureDirectoryExists($tempPath); $deployment->setTemporaryPath($tempPath); - $this->filesystem->requireFile($deploymentPathAndFilename); + require($deploymentPathAndFilename); } else { $this->createLogger()->error(sprintf("The deployment file %s does not exist.\n", $deploymentPathAndFilename)); $deployment = new FailedDeployment(); diff --git a/tests/Unit/Integration/FactoryTest.php b/tests/Unit/Integration/FactoryTest.php index 85b51963..78822b80 100644 --- a/tests/Unit/Integration/FactoryTest.php +++ b/tests/Unit/Integration/FactoryTest.php @@ -225,11 +225,12 @@ public function getWorkspacesBasePathFromPathWithDefinedConstantAndLocalAppDataE */ public function getDeployment(): void { + putenv('HOME=' . __DIR__ . '/Fixtures'); + $files = [getenv('HOME') . '/.surf/deployments/deploy.php']; $this->filesystem->getRealPath('./.surf')->willReturn('foo'); $this->filesystem->isDirectory('foo')->willReturn(false); $this->filesystem->fileExists(Argument::any())->willReturn(true); - $this->filesystem->requireFile(getenv('HOME') . '/.surf/deployments/foo.php'); - $deployment = $this->subject->getDeployment('foo'); + $deployment = $this->subject->getDeployment('deploy'); $this->assertFalse($deployment->getForceRun()); $this->assertTrue($deployment->isInitialized()); } @@ -239,12 +240,12 @@ public function getDeployment(): void */ public function getFirstAndOnlyDeployment(): void { - $files = [getenv('HOME') . '/.surf/deployments/foo.php']; + putenv('HOME=' . __DIR__ . '/Fixtures'); + $files = [getenv('HOME') . '/.surf/deployments/deploy.php']; $this->filesystem->glob(getenv('HOME') . '/.surf/deployments/*.php')->willReturn($files); $this->filesystem->getRealPath('./.surf')->willReturn('foo'); $this->filesystem->isDirectory('foo')->willReturn(false); $this->filesystem->fileExists(Argument::any())->willReturn(true); - $this->filesystem->requireFile(getenv('HOME') . '/.surf/deployments/foo.php'); $this->subject->getDeployment(''); } @@ -253,10 +254,11 @@ public function getFirstAndOnlyDeployment(): void */ public function getDeploymentImplicitlyThrowsException(): void { + putenv('HOME=' . __DIR__ . '/Fixtures'); $this->expectException(InvalidConfigurationException::class); $files = [ - getenv('HOME') . '/.surf/deployments/foo.php', + getenv('HOME') . '/.surf/deployments/deploy.php', getenv('HOME') . '/.surf/deployments/bar.php', ]; $this->filesystem->glob(getenv('HOME') . '/.surf/deployments/*.php')->willReturn($files); diff --git a/tests/Unit/Integration/Fixtures/.surf/deployments/bar.php b/tests/Unit/Integration/Fixtures/.surf/deployments/bar.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/tests/Unit/Integration/Fixtures/.surf/deployments/bar.php @@ -0,0 +1 @@ +