merged branch jfsimon/issue-6749 (PR #7220)

This PR was merged into the 2.1 branch.

Commits
-------

5b19c89 [Console] fixed unparsed StringInput tokens
635b1fc StringInput resets the given options.

Discussion
----------

[Console] fixes unparsed StringInput tokens

`StringInput` instances call `setToken` after constructor, `parse` method is called in constructor, so `StringInput` tokens where never parsed.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6749
This commit is contained in:
Fabien Potencier 2013-02-28 18:08:29 +01:00
commit f52120bdd3
2 changed files with 15 additions and 0 deletions

View File

@ -68,6 +68,7 @@ class ArgvInput extends Input
protected function setTokens(array $tokens)
{
$this->tokens = $tokens;
$this->parse();
}
/**

View File

@ -12,6 +12,8 @@
namespace Symfony\Component\Console\Tests\Input;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class StringInputTest extends \PHPUnit_Framework_TestCase
{
@ -27,6 +29,18 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($tokens, $p->getValue($input), $message);
}
public function testInputOptionWithGivenString()
{
$definition = new InputDefinition(
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
);
$input = new StringInput('--foo=bar', $definition);
$actual = $input->getOption('foo');
$this->assertEquals('bar', $actual);
}
public function getTokenizeData()
{
return array(