コード例 #1
0
ファイル: InputTest.php プロジェクト: CodingFabian/symfony
 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');
     }
 }
コード例 #2
0
 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');
     }
 }
コード例 #3
0
ファイル: InputTest.php プロジェクト: nicolasmartin/symfony
$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');