Beispiel #1
0
}
try {
    $input->getArgument('foo');
    $t->fail('->getArgument() throws a \\InvalidArgumentException if the argument does not exist');
} catch (\InvalidArgumentException $e) {
    $t->pass('->getArgument() throws a \\InvalidArgumentException if the argument does not exist');
}
// ->validate()
$t->diag('->validate()');
$input = new ArrayInput(array());
$input->bind(new Definition(array(new Argument('name', Argument::REQUIRED))));
try {
    $input->validate();
    $t->fail('->validate() throws a \\RuntimeException if not enough arguments are given');
} catch (\RuntimeException $e) {
    $t->pass('->validate() throws a \\RuntimeException if not enough arguments are given');
}
$input = new ArrayInput(array('name' => 'foo'));
$input->bind(new Definition(array(new Argument('name', Argument::REQUIRED))));
try {
    $input->validate();
    $t->pass('->validate() does not throw a \\RuntimeException if enough arguments are given');
} catch (\RuntimeException $e) {
    $t->fail('->validate() does not throw a \\RuntimeException if enough arguments are given');
}
// ->setInteractive() ->isInteractive()
$t->diag('->setInteractive() ->isInteractive()');
$input = new ArrayInput(array());
$t->ok($input->isInteractive(), '->isInteractive() returns whether the input should be interactive or not');
$input->setInteractive(false);
$t->ok(!$input->isInteractive(), '->setInteractive() changes the interactive flag');