merged branch jfsimon/issue-7232-2.1 (PR #7236)

This PR was merged into the 2.1 branch.

Commits
-------

6681df0 [Console] fixed StringInput binding
6b98883 [Console] added string input test
32f1904 Revert "merged branch jfsimon/issue-6749 (PR #7220)"

Discussion
----------

[Console] fixes tests

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7231

---------------------------------------------------------------------------

by gigablah at 2013-03-02T13:25:10Z

Apparently 5b19c892cf broke the console shell. I was wondering why all commands executed through the shell in 2.2.0 were throwing "Too many arguments" exception.

---------------------------------------------------------------------------

by stof at 2013-03-02T13:27:09Z

@gigablah This is already fixed in the 2.2 branch as this PR has already been merged in 2.2 (but the revert is also needed in 2.1)

---------------------------------------------------------------------------

by gigablah at 2013-03-02T13:51:44Z

Ah, guess I'll have to wait for it to be pushed to the symfony/console repository then.
This commit is contained in:
Fabien Potencier 2013-03-06 17:40:53 +01:00
commit 446f56847b
3 changed files with 13 additions and 6 deletions

View File

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

View File

@ -37,9 +37,13 @@ class StringInput extends ArgvInput
*/
public function __construct($input, InputDefinition $definition = null)
{
parent::__construct(array(), $definition);
parent::__construct(array(), null);
$this->setTokens($this->tokenize($input));
if (null !== $definition) {
$this->bind($definition);
}
}
/**

View File

@ -11,9 +11,9 @@
namespace Symfony\Component\Console\Tests\Input;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
class StringInputTest extends \PHPUnit_Framework_TestCase
{
@ -35,10 +35,14 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
);
$input = new StringInput('--foo=bar', $definition);
$actual = $input->getOption('foo');
// call to bind
$input = new StringInput('--foo=bar');
$input->bind($definition);
$this->assertEquals('bar', $input->getOption('foo'));
$this->assertEquals('bar', $actual);
// definition in constructor
$input = new StringInput('--foo=bar', $definition);
$this->assertEquals('bar', $input->getOption('foo'));
}
public function getTokenizeData()