public function testValidate() { $input = new ArrayInput(array()); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); try { $input->validate(); $this->fail('->validate() throws a \\RuntimeException if not enough arguments are given'); } catch (\Exception $e) { $this->assertInstanceOf('\\RuntimeException', $e, '->validate() throws a \\RuntimeException if not enough arguments are given'); $this->assertEquals('Not enough arguments.', $e->getMessage()); } $input = new ArrayInput(array('name' => 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); try { $input->validate(); } catch (\RuntimeException $e) { $this->fail('->validate() does not throw a \\RuntimeException if enough arguments are given'); } }
/** * Do some additional validation of options * * @throws \Exception * @return boolean */ public function validate() { parent::validate(); // s($this->getFullSchemaPath()); // file_exists($this->getFullSchemaPath()); // exit; # GinnyInputException::100 if (strpos($this->getOption('schema_filename'), ',') === false && !file_exists($this->getFullSchemaPath())) { throw new \Foote\Ginny\Exception\GinnyInputException('GinnyInput::getFullSchemaPath invalid: ' . $this->getFullSchemaPath(), 100); } # GinnyInputException::101 if (!file_exists($this->getFullTemplatePath())) { throw new \Foote\Ginny\Exception\GinnyInputException('GinnyInput::getFullTemplatePath invalid: ' . $this->getFullTemplatePath(), 101); } # GinnyInputException::102 if (!file_exists($this->getFullTargetPath())) { throw new \Foote\Ginny\Exception\GinnyInputException('GinnyInput::getFullTargetPath invalid: ' . $this->getFullTargetPath(), 102); } # GinnyInputException::103 if (!class_exists($this->getOption('generator_class'))) { throw new \Foote\Ginny\Exception\GinnyInputException('GinnyInput::getOption(\'generator_class\') invalid: ' . $this->getOption('generator_class'), 103); } }
public function testValidate() { $input = new ArrayInput(array('name' => 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); $this->assertNull($input->validate()); }