Skip to content

Commit

Permalink
Merge pull request #3 from Space48/feature/remove-environment-checking
Browse files Browse the repository at this point in the history
Remove environment checking on command execution
  • Loading branch information
dangron authored May 4, 2018
2 parents d7a8259 + 2e485d6 commit 8668d9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
5 changes: 5 additions & 0 deletions src/ConfigValueSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public static function create(): self
private function __construct()
{
}

public function isEmpty(): bool
{
return empty($this->values);
}
}
23 changes: 10 additions & 13 deletions src/EnvironmentConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$environment = $input->getArgument('environment');

if (!Environment::isValid($environment)) {
throw new \InvalidArgumentException(sprintf(
'Specified environment %s is invalid, accepted environments are %s.',
$environment,
implode(', ', Environment::all())
));
}

$environmentValues = $this
->environmentConfigValuesProvider
->getValues()
Expand All @@ -62,10 +53,16 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->configValueRepository->save($configValue);
}

$output->writeln(sprintf(
'Updated config values for environment %s',
$environment)
);
if ($environmentValues->isEmpty()) {
$output->writeln('No configuration found for environment ' . $environment);
} else {
$output->writeln(sprintf(
'Updated config values for environment %s',
$environment
));
}



return 0;
}
Expand Down
9 changes: 0 additions & 9 deletions test/EnvironmentConfigurationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ class EnvironmentConfigurationCommandTest extends TestCase
/** @var EnvironmentConfigurationCommand */
private $subject;

public function testExecuteFailure()
{
$input = $this->getMockForAbstractClass(InputInterface::class);
$output = $this->getMockForAbstractClass(OutputInterface::class);

$this->expectException(\InvalidArgumentException::class);
$this->subject->execute($input, $output);
}

public function testExecuteSuccess()
{
$input = $this->getMockForAbstractClass(InputInterface::class);
Expand Down

0 comments on commit 8668d9f

Please sign in to comment.