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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Pest test generation #625

Merged
merged 1 commit into from
May 7, 2023
Merged

Add support for Pest test generation #625

merged 1 commit into from
May 7, 2023

Conversation

faustbrian
Copy link
Contributor

This makes the test framework configurable to be either PHPUnit or Pest and then generates tests accordingly, of course defaulting to PHPUnit. The implementation is mostly a bunch of if statements that alternate between 2 strings and for Pest this results in some cases for additional imports being added in the form of use function imports.

@jasonmccreary
Copy link
Collaborator

If I were going to merge this, I'd want to see a separate class, rather than a bunch of if statements. I think a more elegant way would be to register a PestTestGenerator which is commented out, and rename the current to PhpUnitTestGenerator. Users who wish to generate Pest tests may simply toggle the comment, much like a Laravel service provider.

@faustbrian faustbrian marked this pull request as draft May 6, 2023 12:02
config/blueprint.php Outdated Show resolved Hide resolved
@faustbrian
Copy link
Contributor Author

@jasonmccreary I'll work on the separate classes later today or more likely tomorrow. Do you want to keep them completely separate or is an abstract class they extend fine?

@jasonmccreary
Copy link
Collaborator

Not sure it's worth it, but if you want.

@faustbrian
Copy link
Contributor Author

@jasonmccreary went for duplication for now because there's so many small differences that an abstraction would be a bit hacky. Also added tests for everything that the the PHPUnit generator also tests.

@faustbrian faustbrian marked this pull request as ready for review May 7, 2023 01:44
@faustbrian
Copy link
Contributor Author

faustbrian commented May 7, 2023

@jasonmccreary something I wondered while looking at the master branch for tests. Should https://github.com/laravel-shift/blueprint/blob/master/tests/fixtures/drafts/call-to-a-member-function-columns-on-null.yaml#L22-L23 really generate an empty controller https://github.com/laravel-shift/blueprint/blob/master/tests/fixtures/tests/call-to-a-member-function-columns-on-null-TelegramControllerTest.php? I guess because there's no model, if it is expected behaviour?

Edit: I might be blind but resource: all doesn't seem to be a valid value. Seems to be either the resource shorthand or a list of specific methods.

@jasonmccreary
Copy link
Collaborator

This is a pretty large changeset. I'll review it over the next few days.

@jasonmccreary jasonmccreary merged commit 5cd0d9c into laravel-shift:master May 7, 2023
@faustbrian faustbrian deleted the feat/pest-tests branch May 8, 2023 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants