check all configuration in a row

This commit is contained in:
Nicolas Le Goff
2012-02-10 16:51:31 +01:00
parent 77bbd1035f
commit ac1107fc39

View File

@@ -25,10 +25,10 @@ use Alchemy\Phrasea\Core;
*/ */
class module_console_fileConfigCheck extends Command class module_console_fileConfigCheck extends Command
{ {
const PROD = 'prod'; const PROD = 'prod';
const DEV = 'dev'; const DEV = 'dev';
const TEST = 'test'; const TEST = 'test';
const ALERT = 1; const ALERT = 1;
const ERROR = 0; const ERROR = 0;
@@ -50,26 +50,28 @@ class module_console_fileConfigCheck extends Command
{ {
parent::__construct($name); parent::__construct($name);
$this $this->setDescription('check configuration file');
->setDescription('check configuration file')
->addArgument(
'environment'
, InputArgument::REQUIRED
, 'check an environment configuration from configuration file'
);
return $this; return $this;
} }
public function execute(InputInterface $input, OutputInterface $output) public function execute(InputInterface $input, OutputInterface $output)
{ {
$this->env = $input->getArgument('environment');
$this->initTests(); foreach (array(self::DEV, self::PROD, self::TEST) as $env)
{
$output->writeln("");
$output->writeln(sprintf("Checking for %s configuration settings", $env));
$output->writeln("=========================================");
$output->writeln("");
$this->env = $env;
$this->prepareTests($output); $this->initTests();
$this->runTests($output); $this->prepareTests($output);
$this->runTests($output);
}
exit(1); exit(1);
} }
@@ -99,7 +101,7 @@ class module_console_fileConfigCheck extends Command
catch (\Exception $e) catch (\Exception $e)
{ {
$previous = $e->getPrevious(); $previous = $e->getPrevious();
$output->writeln(sprintf( $output->writeln(sprintf(
"<error>%s FATAL error : %s</error>" "<error>%s FATAL error : %s</error>"
, $e->getMessage() , $e->getMessage()
@@ -318,7 +320,7 @@ class module_console_fileConfigCheck extends Command
catch (\Exception $e) catch (\Exception $e)
{ {
$message = sprintf( $message = sprintf(
"%s called from %s in %s:template_engine scope" "%s called from %s in %s:%s:template_engine scope"
, $e->getMessage() , $e->getMessage()
, $this->configuration->getFile()->getFilename() , $this->configuration->getFile()->getFilename()
, $this->env , $this->env
@@ -427,7 +429,7 @@ class module_console_fileConfigCheck extends Command
$serviceBuilder = new Core\ServiceBuilder\Orm( $serviceBuilder = new Core\ServiceBuilder\Orm(
$ormName $ormName
, $configuration , $configuration
, array('registry'=> $registry) , array('registry' => $registry)
); );
$service = $serviceBuilder->buildService(); $service = $serviceBuilder->buildService();
@@ -498,7 +500,7 @@ class module_console_fileConfigCheck extends Command
$e = new \Exception(sprintf( $e = new \Exception(sprintf(
"Missing parameter %s for %s service declared in %s scope." "Missing parameter %s for %s service declared in %s scope."
, $e->getKey() , $e->getKey()
, $templateEngineName , $service->getName()
, $this->env , $this->env
) )
); );