merged branch jfsimon/console-tests-fix (PR #7232)
This PR was merged into the 2.2 branch. Commits -------5bf2f71
[Console] added deprecation annotationf95f8e2
[Console] added string input test4b12118
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
This commit is contained in:
commit
ff00f9856a
@ -68,7 +68,6 @@ class ArgvInput extends Input
|
||||
protected function setTokens(array $tokens)
|
||||
{
|
||||
$this->tokens = $tokens;
|
||||
$this->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,8 @@ class StringInput extends ArgvInput
|
||||
* @param string $input An array of parameters from the CLI (in the argv format)
|
||||
* @param InputDefinition $definition A InputDefinition instance
|
||||
*
|
||||
* @deprecated The second argument is deprecated as it does not work (will be removed in 3.0), use 'bind' method instead
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($input, InputDefinition $definition = null)
|
||||
|
@ -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,7 +35,8 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
|
||||
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
|
||||
);
|
||||
|
||||
$input = new StringInput('--foo=bar', $definition);
|
||||
$input = new StringInput('--foo=bar');
|
||||
$input->bind($definition);
|
||||
$actual = $input->getOption('foo');
|
||||
|
||||
$this->assertEquals('bar', $actual);
|
||||
|
Reference in New Issue
Block a user