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

Skip to content

Commit ff00f98

Browse files
committed
merged branch jfsimon/console-tests-fix (PR #7232)
This PR was merged into the 2.2 branch. Commits ------- 5bf2f71 [Console] added deprecation annotation f95f8e2 [Console] added string input test 4b12118 Revert "merged branch jfsimon/issue-6749 (PR #7220)" Discussion ---------- [Console] fixes tests Previous `StringInputTest::testInputOptionWithGivenString` test was broken. Trying make it pass broke the way `StringInput` is used in the console. Two things to know abour the `StringInput` class in its actual state: * the second argument in the constructor is useless * the `bind` method **must** be called in order to access arguments/options | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes
2 parents 62baab5 + 5bf2f71 commit ff00f98

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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

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

7473
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class StringInput extends ArgvInput
3333
* @param string $input An array of parameters from the CLI (in the argv format)
3434
* @param InputDefinition $definition A InputDefinition instance
3535
*
36+
* @deprecated The second argument is deprecated as it does not work (will be removed in 3.0), use 'bind' method instead
37+
*
3638
* @api
3739
*/
3840
public function __construct($input, InputDefinition $definition = null)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Component\Console\Tests\Input;
1313

14-
use Symfony\Component\Console\Input\StringInput;
1514
use Symfony\Component\Console\Input\InputDefinition;
1615
use Symfony\Component\Console\Input\InputOption;
16+
use Symfony\Component\Console\Input\StringInput;
1717

1818
class StringInputTest extends \PHPUnit_Framework_TestCase
1919
{
@@ -35,7 +35,8 @@ public function testInputOptionWithGivenString()
3535
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
3636
);
3737

38-
$input = new StringInput('--foo=bar', $definition);
38+
$input = new StringInput('--foo=bar');
39+
$input->bind($definition);
3940
$actual = $input->getOption('foo');
4041

4142
$this->assertEquals('bar', $actual);

0 commit comments

Comments
 (0)