Closed

Description
Following the example set at the bottom of this dialog helper page
http://symfony.com/doc/current/components/console/helpers/dialoghelper.html
When I attempt to run the following test
public function test_interactive_dialogue()
{
// ...
$command = new SomeCommand();
$commandTester = new CommandTester($command);
$dialog = $command->getHelper('dialog');
$dialog->setInputStream($this->getInputStream("Test\n"));
$commandTester->execute(array('command' => $command->getName()));
}
protected function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
fputs($stream, $input);
rewind($stream);
return $stream;
}
I get the following exception stack
PHP Fatal error: Call to a member function get() on a non-object in
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main()
PHP 3. PHPUnit_TextUI_Command->run()
PHP 4. PHPUnit_TextUI_TestRunner->doRun()
PHP 5. PHPUnit_Framework_TestSuite->run()
PHP 6. PHPUnit_Framework_TestCase->run()
PHP 7. PHPUnit_Framework_TestResult->run()
PHP 8. PHPUnit_Framework_TestCase->runBare()
PHP 9. PHPUnit_Framework_TestCase->runTest()
PHP 10. ReflectionMethod->invokeArgs()
PHP 11. SQLUp\Tests\WrapperCommands\GlobalConfigCommandTest->test_interactive_dialogue()
PHP 12. Symfony\Component\Console\Command\Command->getHelper()
on this specific line
$dialog->setInputStream($this->getInputStream("Test\n"));
It's calling the getHelper method on a object that doesn't have it, the command method instead of the dialogue method that's being utilized in the execute method implemented.
This code works, I've tested it from command line, the test doesn't reflect that though, the exception is correct, but the example needs to be updated to address this issue on the symfony 2 docs.
Metadata
Metadata
Assignees
Labels
No labels