Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[make:*] add ability to generate tests #1497

Merged
merged 3 commits into from Apr 21, 2024

Conversation

jrushlow
Copy link
Collaborator

@jrushlow jrushlow commented Apr 2, 2024

This feature is experimental - generated code is likely to change significantly between point releases.

Adds the ability to pass --with-tests to make:registration, make:reset-password, & make:crud and maker will generate a new PHPUnit test tailored for the specific functionality of that maker. If --with-tests is not passed as an argument, MakerBundle will ask the user Do you want to generate PHPUnit tests? [Experimental].

This PR introduces a new internal CanGenerateTestsTrait that can be added to any Maker command. The method naming is intended to be intuitive - e.g. configureCommandWithTestsOption() should be called from configureCommand(), interactSetGenerateTests() called in interact(), & shouldGenerateTests() is used in the generate() method in a conditional to determine if the command should generate test code.

The userland tests we generate are run against the code generated by their respective makers in our test suite. This should be the case for any tests created going forward.

The tests are created under the App\Tests namespace and created in the tests/ dir. Possibly in the future we can customize this behavior - but for now - attempting to guess the correct test dir structure && keep everyone happy is outside the scope of this PR 馃槣

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels Apr 2, 2024
@jrushlow jrushlow force-pushed the feature/with-tests branch 4 times, most recently from ceb2043 to ea34834 Compare April 17, 2024 19:29
@jrushlow jrushlow marked this pull request as ready for review April 17, 2024 21:41
@jrushlow jrushlow added Status: Needs Review Needs to be reviewed and removed Status: Needs Work Additional work is needed labels Apr 18, 2024
@jrushlow jrushlow merged commit e7ea13d into symfony:main Apr 21, 2024
7 checks passed
@jrushlow jrushlow deleted the feature/with-tests branch April 21, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant