Skip to content
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

Unexpected behaviour with instance mocks/overload #1200

Open
diedexx opened this issue Nov 17, 2022 · 0 comments
Open

Unexpected behaviour with instance mocks/overload #1200

diedexx opened this issue Nov 17, 2022 · 0 comments

Comments

@diedexx
Copy link

diedexx commented Nov 17, 2022

The Mockery docs about overloading mention:

Using alias/instance mocks across more than one test will generate a fatal error since we can’t have two classes of
the same name. To avoid this, run each test of this kind in a separate PHP process (which is supported out of the box by
both PHPUnit and PHPT).

Instead of a fatal error, I see some odd behaviour that could either be a bug or something that should be documented:

I can overload the same class multiple times in the same PHP process. When I overload a class twice in the same test (which I did to find the limits of creating instance mocks), I found that only the expectations of the first overload are taken into account. Any assertions on a second overload of the same class are ignored without warning.

Here's the code that I used: https://github.com/jrfnl/bug-report-reproduction-scenarios/tree/mockery/overload-implementation-question

Am I interpreting the docs incorrectly? When should I expect a fatal error when creating instance mocks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant