public function testParseEmptyStringArgument() { $input =
new ArgvInput(['cli.php', '-f', 'bar', ''
]);
$input->
bind(new InputDefinition([new InputArgument('empty'
),
new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL
)]));
$this->
assertEquals(['empty' => ''
],
$input->
getArguments(), '->parse() parses empty string arguments'
);
} public function testGetFirstArgument() { $input =
new ArgvInput(['cli.php', '-fbbar'
]);
$this->
assertNull($input->
getFirstArgument(), '->getFirstArgument() returns null when there is no arguments'
);
$input =
new ArgvInput(['cli.php', '-fbbar', 'foo'
]);
$this->
assertEquals('foo',
$input->
getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input'
);
$input =
new ArgvInput(['cli.php', '--foo', 'fooval', 'bar'
]);
$input->
bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL
),
new InputArgument('arg'
)]));
$this->
assertSame('bar',
$input->
getFirstArgument());
$input =
new ArgvInput(['cli.php', '-bf', 'fooval', 'argval'
]);
$input->
bind(new InputDefinition([new InputOption('bar', 'b', InputOption::VALUE_NONE
),
new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL
),
new InputArgument('arg'
)]));
$this->
assertSame('argval',
$input->
getFirstArgument());
}