Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f52120b

Browse files
committed
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
2 parents 66c2be3 + 5b19c89 commit f52120b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function __construct(array $argv = null, InputDefinition $definition = nu
6868
protected function setTokens(array $tokens)
6969
{
7070
$this->tokens = $tokens;
71+
$this->parse();
7172
}
7273

7374
/**

src/Symfony/Component/Console/Tests/Input/StringInputTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Console\Tests\Input;
1313

1414
use Symfony\Component\Console\Input\StringInput;
15+
use Symfony\Component\Console\Input\InputDefinition;
16+
use Symfony\Component\Console\Input\InputOption;
1517

1618
class StringInputTest extends \PHPUnit_Framework_TestCase
1719
{
@@ -27,6 +29,18 @@ public function testTokenize($input, $tokens, $message)
2729
$this->assertEquals($tokens, $p->getValue($input), $message);
2830
}
2931

32+
public function testInputOptionWithGivenString()
33+
{
34+
$definition = new InputDefinition(
35+
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
36+
);
37+
38+
$input = new StringInput('--foo=bar', $definition);
39+
$actual = $input->getOption('foo');
40+
41+
$this->assertEquals('bar', $actual);
42+
}
43+
3044
public function getTokenizeData()
3145
{
3246
return array(

0 commit comments

Comments
 (0)