本文整理匯總了PHP中Symfony\Component\Console\Input\ArrayInput::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayInput::validate方法的具體用法?PHP ArrayInput::validate怎麽用?PHP ArrayInput::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Input\ArrayInput
的用法示例。
在下文中一共展示了ArrayInput::validate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testValidate
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');
}
}
示例2: validate
/**
* 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);
}
}
示例3: testValidate
public function testValidate()
{
$input = new ArrayInput(array('name' => 'foo'));
$input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED))));
$this->assertNull($input->validate());
}