Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Console] Add support for Invokable Commands inCommandTester#60823

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:7.4fromruudk:invokable-commands
Jun 23, 2025

Conversation

@ruudk
Copy link
Contributor

@ruudkruudk commentedJun 18, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

I'm trying out the amazing newInvokable Commands introduced in Symfony 7.3 but I noticed that I could use it together with the CommandTester. It was also not possible to manually add these type of commands to the Application.

I'm not sure what the best approach is with this. As I'm changing the signature of the methods this might be considered a breaking change. Or it might not, as I'm widening the type from Command to object.

Please advise what the best approach would be to introduce something like this. Thanks 🙏

/cc@yceruto@chalasr

GromNaN, alamirault, and mztrix reacted with thumbs up emoji
@ruudkruudk requested a review fromchalasr as acode ownerJune 18, 2025 12:45
@carsonbotcarsonbot added this to the7.3 milestoneJun 18, 2025
@ruudkruudk changed the title[Console] Invokable commands[Console] Add support for Invokable Commands in CommandTester and ApplicationJun 18, 2025
@ruudkruudk changed the title[Console] Add support for Invokable Commands in CommandTester and Application[Console] Add support for Invokable Commands inCommandTester andApplicationJun 18, 2025
@ruudk
Copy link
ContributorAuthor

Sure I could wrap them manually innew Command()->setCode($theCommand) but that feels nasty from a user perspective.

@GromNaNGromNaN changed the base branch from7.3 to7.4June 18, 2025 13:32
@GromNaN
Copy link
Member

I updated the target branch to 7.4, this is a new feature that cannot be merged into 7.3

@ruudkruudkforce-pushed theinvokable-commands branch 2 times, most recently from2e104a7 tobeea196CompareJune 18, 2025 13:42
@ruudk
Copy link
ContributorAuthor

Thanks, it seems that the Application was already fixed in 7.4#60394

@ruudkruudk changed the title[Console] Add support for Invokable Commands inCommandTester andApplication[Console] Add support for Invokable Commands inCommandTesterJun 18, 2025
Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's good, there are a few things to fix to clean up the PR.
Thanks for the new test.

@ruudk
Copy link
ContributorAuthor

ruudk commentedJun 18, 2025
edited
Loading

@GromNaN Done, also updated the changelog!

@GromNaNGromNaN self-requested a reviewJune 19, 2025 08:54
Copy link
Member

@GromNaNGromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The test needs to be modified, and then we're all good!

@ruudk
Copy link
ContributorAuthor

@GromNaN Done, I also added another commit with extra tests.

@ruudk
Copy link
ContributorAuthor

@GromNaN@yceruto Thanks for the thorough reviews and guidance on this 👏

Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks@ruudk for the improvement!

ruudk reacted with hooray emoji
@fabpotfabpot modified the milestones:7.3,7.4Jun 23, 2025
@fabpot
Copy link
Member

Thank you@ruudk.

@fabpotfabpot merged commit138109a intosymfony:7.4Jun 23, 2025
10 of 11 checks passed
@GromNaN
Copy link
Member

I got the question about testing invokable commands in Symfony 7.3. While this feature will be released in Symfony 7.4, here are two solutions:

  1. Create aCommand object and inject the invokable command: You can achieve this by doingnew CommandTester((new Command)->setCode($invokableCommand))).
  2. Directly test the__invoke method of your class: treat it like a unit test, usingArrayInput andBufferedOutput.
tdutrion reacted with thumbs up emoji

@chalasr
Copy link
Member

Third testing option for 7.3: useApplicationTester, same capabilities asCommandTester

GromNaN and tdutrion reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@HypeMCHypeMCHypeMC left review comments

@fabpotfabpotfabpot approved these changes

@GromNaNGromNaNGromNaN approved these changes

@ycerutoycerutoyceruto approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

8 participants

@ruudk@GromNaN@fabpot@chalasr@stof@yceruto@HypeMC@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp