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

Skip to content

[Console] fixes tests #7232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Symfony/Component/Console/Input/ArgvInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function __construct(array $argv = null, InputDefinition $definition = nu
protected function setTokens(array $tokens)
{
$this->tokens = $tokens;
$this->parse();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Console/Input/StringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/Console/Tests/Input/StringInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -35,7 +35,8 @@ public function testInputOptionWithGivenString()
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
);

$input = new StringInput('--foo=bar', $definition);
$input = new StringInput('--foo=bar');
$input->bind($definition);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfsimon Wouldn't it be possible to call bind at the end of the constructor so that the argument is working ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe to call the parent constructor only after tokenizing ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if the argument is deprecated it should be removed from the constructor signature. And you func_get_args instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tobion there is a pending PR making it work properly again, so there will be no reason to deprecate it because being broken.

$actual = $input->getOption('foo');

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