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

Skip to content

[Cookbook] Example shown doesn't work for unit testing ConsoleCommand #2870

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

Closed
gena01 opened this issue Jul 31, 2013 · 9 comments
Closed

[Cookbook] Example shown doesn't work for unit testing ConsoleCommand #2870

gena01 opened this issue Jul 31, 2013 · 9 comments
Labels
actionable Clear and specific issues ready for anyone to take them. bug Console good first issue Ideal for your first contribution! (some Symfony experience may be required)

Comments

@gena01
Copy link

gena01 commented Jul 31, 2013

The section here has a typo:
http://symfony.com/doc/current/cookbook/console/console_command.html#testing-commands

Seems like adding another line:
'command' => $command->getName(),
before the name key fixes the issue for me.

@xabbuh
Copy link
Member

xabbuh commented Jul 31, 2013

What exactly does not work without this line? Do you get any errors?

@gena01
Copy link
Author

gena01 commented Jul 31, 2013

I get exceptions from the Input.php class that a required argument is missing. It also differs from this doc that seems to have the correct example: http://symfony.com/doc/current/components/console/introduction.html#testing-commands

   $commandTester->execute(
        array('command' => $command->getName(), 'name' => 'Fabien')
    );

@wouterj
Copy link
Member

wouterj commented Jul 31, 2013

It was removed quite recently in 16e5577

If I remember correctly, you get indeed errors when you are missing the command option.

Let's put the 2 removed lines (see commit) back!

@xabbuh
Copy link
Member

xabbuh commented Aug 1, 2013

The problem for me is that I can't reproduce this errors, not even on a fresh 2.3 installation.

@wouterj
Copy link
Member

wouterj commented Aug 1, 2013

I created a gist: https://gist.github.com/WouterJ/6129648

Without command it produces a RuntimeException: Not enough arguments in Symfony\Component\Console\Input\Input on line 76

@xabbuh
Copy link
Member

xabbuh commented Aug 1, 2013

This seems to be a bug. If you create a Command that has arguments, everything is fine. Additionally, it even doesn't matter which value you pass for the command argument.

@dlondero
Copy link
Contributor

Was about to open an issue for this problem then found this. Bumped also the other issue for the bug.

@xabbuh
Copy link
Member

xabbuh commented Oct 1, 2013

@gena01 can you confirm that this problem has been fixed with symfony/symfony@50c8050?

@xabbuh
Copy link
Member

xabbuh commented Oct 3, 2013

Actually, symfony/symfony@50c8050 won't be merged into 2.2 or 2.3, but will only be a new feature in 2.4. Thus, we need to add the removed lines again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. bug Console good first issue Ideal for your first contribution! (some Symfony experience may be required)
Projects
None yet
Development

No branches or pull requests

4 participants