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 phpstorm metadata for mock methods when testing #1405

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

bentleyo
Copy link
Contributor

@bentleyo bentleyo commented Jan 16, 2023

Summary

This adds some PhpStorm metadata to help with the return type when calling the $this->mock, $this->partialMock etc. methods in tests. By default PhpStorm believes the return type is an object implementing MockInterface, but this PR adds an additional typehint for the mocked class.

Here is an example in a test:

$user = $this->mock(User::class);

PhpStorm will now say the return type is App\Models\User&Mockery\MockInterface.

Screen Shot 2023-01-16 at 13 46 41

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Add a CHANGELOG.md entry

@bentleyo bentleyo changed the title Add phpstorm metadata for testing Add phpstorm metadata for mock methods when testing Jan 16, 2023
Copy link
Collaborator

@mfn mfn left a comment

Choose a reason for hiding this comment

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

LGTM!

@mfn mfn requested a review from barryvdh January 17, 2023 10:29
@barryvdh barryvdh merged commit f055d42 into barryvdh:master Jan 17, 2023
d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this pull request Feb 16, 2024
* Add phpstorm metadata for testing

* Update CHANGELOG.md
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.

3 participants