Пример #1
0
 public function testGetFirstArgument()
 {
     $input = new ArrayInput(array());
     $this->assertEquals($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed');
     $input = new ArrayInput(array('name' => 'Fabien'));
     $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');
     $input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien'));
     $this->assertEquals($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');
 }
Пример #2
0
use Symfony\Components\Console\Input\ArrayInput;
use Symfony\Components\Console\Input\InputDefinition;
use Symfony\Components\Console\Input\InputArgument;
use Symfony\Components\Console\Input\InputOption;

$t = new LimeTest(15);

// ->getFirstArgument()
$t->diag('->getFirstArgument()');
$input = new ArrayInput(array());
$t->is($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed');
$input = new ArrayInput(array('name' => 'Fabien'));
$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');
$input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien'));
$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');

// ->hasParameterOption()
$t->diag('->hasParameterOption()');
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
$t->ok(!$input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters');

$input = new ArrayInput(array('--foo'));
$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');

// ->parse()
$t->diag('->parse()');
$input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'))));
$t->is($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments');