-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Method with()
on test doubles yields error with static analyzer
#6154
Comments
Thank you for your report. Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue. |
Sure here is a minimal example: |
with()
on test doubles yields error with static analyzer
Thank you for the very quick response 💪 |
You're welcome. Were you able to verify that the change solves your problem? |
Yes, I've just checked commit |
@nreynis @sebastianbergmann Have you taken into consideration the following cases? I am having a different problem. from https://github.com/nreynis/phpunit-6154 public function testMockGet(): void
{
$mockedService = $this->createMock(MyService::class);
$mockedService
+ ->expects($this->exactly(1))
->method('get')
->with(24)
->willReturn('24');
$this->assertSame('24', $mockedService->get(24));
}
|
Please do not use an existing issue to discuss a new / different issue. If your issue still exists in PHPUnit 12.0.9 then please open a new issue. Thank you. That being said, your issue might be related to PHPStan's cache (as PHPUnit 12.0.9 no longer has |
@sebastianbergmann I'm Sorry. I created new issue. (#6156) |
Summary
This piece of code works, but does not pass static analysis anymore.
The test still run correctly but does not pass a PHPStan analysis anymore:
In PHPUnit 11
method
returned anInvocationMocker
I can workaround by using
willReturnMap
, but I haven't seen any deprecation, or anything in the release notes. The documentation still has examples with the same construction (ie: https://docs.phpunit.de/en/12.0/test-doubles.html#id34).Should I change my code or is this an unwanted side-effect of refactoring?
Current behavior
Fail static analysis
How to reproduce
See minimal example: https://github.com/nreynis/phpunit-6154
Expected behavior
The text was updated successfully, but these errors were encountered: