-
-
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
catchable fatal error in 3.5 #74
Comments
I will need a small reproducing test case to investigate this further. |
I've made hours worth of changes since then and worked around the problem, but (I believe) it centered around trying to (erroneously) throw an abstract Exception class. I'm continuing to dig through my change logs and if I can roll back to a non-working state and isolate this I'll let you know. Thanks. |
here is the recipe: |
Should be fixed. |
sorry for making noise here again, in what version should it be fixed? i just checked against PHPUnit 3.5.10 and it still shows that error: regards cobexer |
It should have been fixed in PHPUnit 3.5.10. Please provide a small yet complete reproducing example so that I can further investigate. |
still happens with the example posted above! |
Still reproducing phpunit 3.5.13 / centos 5 |
I also reproduced this: phpunit 3.5.13, ubuntu 10.04. |
This is actually expected behavior if you understand how process isolation works. During process isolation you have one main PHPUnit process that is collecting tests and then a separate PHPUnit process for each test that the main process collects. When one of the separate test processes finishes, it serializes the results and sends them back to the main process. The problem with your code is that the separate test process is including a file which defines a new exception class that the main process knows nothing about. So when your test throws this new exception, it gets serialized as part of the result object and sent back to the main process. When the main process tries to unserialize the result object, PHP gives a The remedy for this is pretty simple: be cognizant of how process isolation works and make sure that you are not hiding classes from the main process. The simplest way to do this is to move your file include outside of the class definition. A better way is to use an autoloader. |
My main concern with this is that a test that fails and unexpectedly throws an unknown exception crashes the PHPUnit main process! fixing this in my code is easy, but if it fails it destroys the complete test run. and fixing such a problem in a third party library may not be easy / wanted. |
I think it's definitely possible for PHPUnit to handle this more gracefully (and @sebastianbergmann may have some desire to do so), but ultimately the problem is that you're structuring your test in a way that is not compatible with process isolation. If you structure your tests properly, you won't ever encounter this and it won't matter how PHPUnit handles it. |
Hmm i do something and as a result PHPUnit crashes, oh of course i must be I still think it's a bug and should be fixed.
|
I've acknowledged that PHPUnit could handle this situation more gracefully–I was actually planning on looking into this later tonight. I just wanted to help you understand what's going on and how to avoid this situation as it can take a while before patches make it into an official release of PHPUnit and there's no guarantee that Sebastian will accept a patch for this. |
That would be great! |
What is the status of this issue? Is it fixed or left as it is? If fixed in which release will it be shipped? |
Catchable fatal error: Argument 2 passed to PHPUnit_Framework_TestResult::addError() must be an instance of Exception, instance of __PHP_Incomplete_Class given, called in /Applications/MAMP/bin/php5.3/lib/php/PHPUnit/Util/PHP.php on line 222 and defined in /Applications/MAMP/bin/php5.3/lib/php/PHPUnit/Framework/TestResult.php on line 237
Using the command-line test runner
The text was updated successfully, but these errors were encountered: