Esempio n. 1
0
 public function testValidate()
 {
     $option = $this->getMock('Magento\\Framework\\Setup\\Option\\TextConfigOption', [], [], '', false);
     $option->expects($this->exactly(3))->method('getName')->willReturn('Fake');
     $optionsSet = [$option, $option, $option];
     $configOption = $this->configOptionsList;
     $configOption->expects($this->once())->method('getOptions')->will($this->returnValue($optionsSet));
     $configOption->expects($this->once())->method('validate')->will($this->returnValue([]));
     $this->collector->expects($this->exactly(2))->method('collectOptionsLists')->will($this->returnValue([$configOption]));
     $this->configModel->validate(['Fake' => null]);
 }
 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $inputOptions = $input->getOptions();
     $errors = $this->configModel->validate($inputOptions);
     if (!empty($errors)) {
         foreach ($errors as $error) {
             $output->writeln("<error>{$error}</error>");
         }
         throw new \InvalidArgumentException('Parameter validation failed');
     }
 }
Esempio n. 3
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');
     }
 }