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 (\RuntimeException $e) { } $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'); } }
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'); } }
$t->diag('->validate()'); $input = new ArrayInput(array()); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::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 InputDefinition(array(new InputArgument('name', InputArgument::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');