-
-
Notifications
You must be signed in to change notification settings - Fork 738
Closed
rectorphp/rector-phpunit
#546Description
Processing file with this rule ends up in the not valid code (at least on PHPUnit v 9.6.23)
Sample change
1) tests/SampleTest.php:79
---------- begin diff ----------
@@ @@
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)
->disableOriginalConstructor()
->onlyMethods(['dispatch'])
->getMock()
;
+ /* @phpstan-ignore-next-line method.deprecated (no alternative?) */
+ $matcher = self::exactly(2);
/* @phpstan-ignore-next-line method.deprecated (no alternative?) */
- $eventDispatcher->expects(self::exactly(2))
- ->method('dispatch')
- ->withConsecutive(
- [self::isInstanceOf(SubscribedEvent::class)],
- [self::isInstanceOf(UnsubscribedEvent::class)]
- )
+ $eventDispatcher->expects($matcher)
+ ->method('dispatch')->willReturnCallback(function (...$parameters) use ($matcher): void {
+ if ($matcher->numberOfInvocations() === 1) {
+ $this->assertSame(self::isInstanceOf(SubscribedEvent::class), $parameters[0]);
+ }
+ if ($matcher->numberOfInvocations() === 2) {
+ $this->assertSame(self::isInstanceOf(UnsubscribedEvent::class), $parameters[0]);
+ }
+ })
Error: Call to undefined method PHPUnit\Framework\MockObject\Rule\InvokedCount::numberOfInvocations()
Metadata
Metadata
Assignees
Labels
No labels