-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
"Class does not exist" warning when MockBuilder::addMethods() used #3985
Comments
Thank you for your report. Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue. |
This results in the following: 1) ExampleTest::testFails It works if |
I would love to see a fix for this. |
Something new to this (happens to me too under PHP v8.1.13 and PHPUnit v9.5.26) ? And ...happy holidays everyone :-) |
Any updates on this? Getting the same warning using PHP 8.0.23 and PHPUnit 8.5.28. |
|
Encountered the same issue using PHPUnit 10.0.15. Is there any way to create a mock object for the class that does not exist yet? Or should we just wait for PHPUnit 10.1 release? What will be a replacement for the getMockBuilder() then? |
I know this is a old thread, but with the latest version of PHPUnit (11), it seems there is still no way to mock a class that doesn't exist yet. Is this just not possible? |
This issue is related to the
MockBuilder::setMethods()
method being deprecated, and replaced withaddMethods()
andonlyMethods()
(detailed in issue 3911).I currently have this code for creating a mock "PaymentGateway" object with a stubbed "charge" method, and it works:
However, with
setMethods
being deprecated, I've tried to replace it withaddMethods
:However this gives me a Class PaymentGateway does not exist warning.
Does the class actually need to exist before we can mock it? Or am I misunderstanding how
addMethods
works?The text was updated successfully, but these errors were encountered: