Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

call to member function get on a non object #12798

Copy link
Copy link
Closed
@ghost

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.