Skip to content

[WebProfilerBundle] do not base services on PHPUnit mocks #58413

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

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 29, 2024

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT

Using the service container to build services bypasses PHPUnit's mock system which means that there is no guarantuee that objects are initialized in a way expected by PHPUnit. Thus mocks may or may not work as expected.

@xabbuh xabbuh force-pushed the container-mock-register branch from 6b0ec7c to facd698 Compare September 29, 2024 11:14
@stof
Copy link
Member

stof commented Sep 30, 2024

The only valid usage of a mock for a service would be for setting an existing instance for a service.

Using the service container to build services bypasses PHPUnit's mock system
which means that there is no guarantuee that objects are initialized in a way
expected by PHPUnit. Thus mocks may or may not work as expected.
@xabbuh xabbuh force-pushed the container-mock-register branch from facd698 to 6ed0797 Compare September 30, 2024 08:45
@xabbuh xabbuh merged commit e6e545c into symfony:5.4 Sep 30, 2024
11 of 12 checks passed
@xabbuh xabbuh deleted the container-mock-register branch September 30, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants