Skip to content

Commit

Permalink
Remove environment checking on command execution
Browse files Browse the repository at this point in the history
Different projects run in many different environments, do not be
opinionated about their names.
  • Loading branch information
dank00 committed May 4, 2018
1 parent d7a8259 commit 2e485d6
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 2e485d6

Please sign in to comment.