-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: Handle command defined with AsCommand php attribute #24
Conversation
src/TestCommand.php
Outdated
@@ -56,6 +57,9 @@ public static function for(Command $command): self | |||
public static function from(Application $application, string $cli): self | |||
{ | |||
foreach ($application->all() as $commandObject) { | |||
if ($commandObject instanceof LazyCommand) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure if this is the right way to do it.
name: 'fixture:command', | ||
description: 'zenstruck/console-test command for tests' | ||
)] | ||
final class FixtureAttributeCommand extends Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have copy past your other FixtureCommand but without cleaning it
Maybe tests should be duplicated for this case (with #[AsCommand] attribute) ?
@kbond do you it's good ? Tell me if I can add something |
Sorry for the delay here... holidays :) This is a great catch! I've simplified it a bit in #27. The root issue wasn't actually the attribute but having a default description on your command (Symfony uses the attribute to determine this). When you have a default description, Symfony marks the command as lazy (the default description is the trigger). Thank you! |
Hope you had great holidays ! Thank you for the clarification |
It seems that the
#[AsCommand]
attribute make commands lazyWhen using this phpunit helper lib I am unable to launch command from tests