-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature/test-doublesTest Stubs and Mock ObjectsTest Stubs and Mock Objectstype/bugSomething is brokenSomething is brokenversion/12Something affects PHPUnit 12Something affects PHPUnit 12
Description
Q | A |
---|---|
PHPUnit version | 12 |
PHP version | 8.3 |
Installation Method | Composer |
Summary
This piece of code works, but does not pass static analysis anymore.
$this->createMock(MyService::class)
->method('get')
->with($id)
->willReturn($value);
The test still run correctly but does not pass a PHPStan analysis anymore:
Call to an undefined method
PHPUnit\Framework\MockObject\Builder\InvocationStubber::with().
In PHPUnit 11 method
returned an InvocationMocker
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
Metadata
Metadata
Assignees
Labels
feature/test-doublesTest Stubs and Mock ObjectsTest Stubs and Mock Objectstype/bugSomething is brokenSomething is brokenversion/12Something affects PHPUnit 12Something affects PHPUnit 12