Skip to content

Commit

Permalink
Merge 1869346 into bbcdc3f
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed Mar 10, 2020
2 parents bbcdc3f + 1869346 commit 6a6e203
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Command/DeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/RollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/SimulateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 1 addition & 6 deletions src/Domain/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -70,9 +70,4 @@ public function glob(string $pattern): array
{
return glob($pattern);
}

public function requireFile(string $file): void
{
require($file);
}
}
2 changes: 0 additions & 2 deletions src/Domain/Filesystem/FilesystemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Integration/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 7 additions & 5 deletions tests/Unit/Integration/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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('');
}

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Integration/Fixtures/.surf/deployments/bar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php

0 comments on commit 6a6e203

Please sign in to comment.