/**
  * @dataProvider validateDataProvider
  * @param bool[] $options
  * @param string[] $errors
  */
 public function testValidate(array $options, array $errors)
 {
     $inputMock = $this->getMockForAbstractClass('Symfony\\Component\\Console\\Input\\InputInterface', [], '', false);
     $index = 0;
     foreach ($options as $option) {
         $inputMock->expects($this->at($index++))->method('getOption')->willReturn($option);
     }
     $this->assertEquals($errors, $this->command->validate($inputMock));
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $inputOptions = $input->getOptions();
     $configOptionsToValidate = [];
     foreach ($this->configModel->getAvailableOptions() as $option) {
         if (array_key_exists($option->getName(), $inputOptions)) {
             $configOptionsToValidate[$option->getName()] = $inputOptions[$option->getName()];
         }
     }
     $errors = $this->configModel->validate($configOptionsToValidate);
     $errors = array_merge($errors, $this->adminUser->validate($input));
     if (!empty($errors)) {
         foreach ($errors as $error) {
             $output->writeln("<error>{$error}</error>");
         }
         throw new \InvalidArgumentException('Parameters validation is failed');
     }
 }