-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Feature | Accept type-hinted requests as assertSent
parameters
#424
base: v3
Are you sure you want to change the base?
Conversation
3f03f8e
to
aeee994
Compare
I ignored the phpstan errors as they seem to be false-positives. |
For some reason, I can't get GitHub to let me comment on the changes on my tablet, so I'll make a regular comment for now. The PHPStan errors around the Reflection APIs might need an extra look. new ReflectionFunction($callable(...)); I'm not 100 % sure on the ReflectionType for the parameters. |
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.
The PR looks okay to me. I don't think we need these PHPStan exclusions?
|
||
- | ||
message: "#^Method Saloon\\\\Http\\\\Faking\\\\MockClient\\:\\:getRequestClass\\(\\) should return class-string|null but returns class-string<Saloon\\\\Http\\\\Request>|Saloon\\\\Http\\\\Request$#" | ||
count: 1 | ||
path: src/Http/Faking/MockClient.php | ||
|
||
- | ||
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Http/Faking/MockClient.php | ||
|
||
- | ||
message: "#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure|string, callable\\(\\)\\: mixed given\\.$#" | ||
count: 1 | ||
path: src/Http/Faking/MockClient.php |
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.
- | |
message: "#^Method Saloon\\\\Http\\\\Faking\\\\MockClient\\:\\:getRequestClass\\(\\) should return class-string|null but returns class-string<Saloon\\\\Http\\\\Request>|Saloon\\\\Http\\\\Request$#" | |
count: 1 | |
path: src/Http/Faking/MockClient.php | |
- | |
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#" | |
count: 1 | |
path: src/Http/Faking/MockClient.php | |
- | |
message: "#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure|string, callable\\(\\)\\: mixed given\\.$#" | |
count: 1 | |
path: src/Http/Faking/MockClient.php |
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.
assertSent
parametersassertSent
parameters
Closes #417
This pull request adds support for type-hinting a request class as the first parameter of the closure passed to
MockClient#assertSent
. This allows running this kind of test:Before this pull request, the test above could only be written using a condition: