-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Mailer] do not use PHPUnit mock objects without configured expectations #62756
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
Conversation
xabbuh
commented
Dec 12, 2025
| Q | A |
|---|---|
| Branch? | 6.4 |
| Bug fix? | yes |
| New feature? | no |
| Deprecations? | no |
| Issues | part of #62669 |
| License | MIT |
8115e87 to
b5dbe6a
Compare
b5dbe6a to
494fa91
Compare
nicolas-grekas
left a comment
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.
🎉 thanks for working on this!
| protected function getDispatcher(): EventDispatcherInterface | ||
| { | ||
| return $this->dispatcher ??= $this->createMock(EventDispatcherInterface::class); | ||
| return $this->dispatcher ??= new EventDispatcher(); | ||
| } |
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.
What was the use case of those protected method ?
Cause if someone did
$this->getDispatcher->expect(self::once())->method('dispatch');
This won't work anymore (so could be called a BC break ?)
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 return type of the method is EventDispatcherInterface. If you want still use a mock object, you can override the method.
|
Thank you @xabbuh. |