[Console] fixed StringInput binding
This commit is contained in:
parent
6b98883903
commit
6681df0a12
@ -37,9 +37,13 @@ class StringInput extends ArgvInput
|
|||||||
*/
|
*/
|
||||||
public function __construct($input, InputDefinition $definition = null)
|
public function __construct($input, InputDefinition $definition = null)
|
||||||
{
|
{
|
||||||
parent::__construct(array(), $definition);
|
parent::__construct(array(), null);
|
||||||
|
|
||||||
$this->setTokens($this->tokenize($input));
|
$this->setTokens($this->tokenize($input));
|
||||||
|
|
||||||
|
if (null !== $definition) {
|
||||||
|
$this->bind($definition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,11 +35,14 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
|
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// call to bind
|
||||||
$input = new StringInput('--foo=bar');
|
$input = new StringInput('--foo=bar');
|
||||||
$input->bind($definition);
|
$input->bind($definition);
|
||||||
$actual = $input->getOption('foo');
|
$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()
|
public function getTokenizeData()
|
||||||
|
Reference in New Issue
Block a user