-
-
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
Wrong class autoloading and conflicts #2014
Comments
This isn't really a composer issue, and there is nothing we can do about it. The solution for phpunit might come with https://github.com/webmozart/php-scoper - in the meantime requiring it in your project is the best way, and I'd anyway argue it's the best way as it's the only way to guarantee you get the right phpunit version for every project. |
Thanks for answering.
Well, adding PHPUnit with all dependencies on each project is quite painful IMO but yes, there is many way to do. Anyway, PHPUnit can be installed on system wide (even if via apt-get) and I think this should work on standalone process.
If I understand well this tools, this should be added on PHPUnit project to generate a unique namespace for the .phar of composer global install, right? |
Right. |
Sorry but why closing this issue? If PHP-scoper is the solution, we should wait to implement it before closing. |
As a workaround, @sebastianbergmann might want to bundle the release of |
This issue is affecting me too, I can't really understand why. Running the phpunit binary on my project folder don't work. Running it from |
php-scoper has now stable released. Could this be reconsidered? EDIT: Only vendor should be prefixed, not PHPUnit classes to avoid confusion on IDE completion for example. |
#2015 won't be implemented in time for PHPUnit 7.0. I am hoping for PHPUnit 7.1. |
This issue is the continuing of #1757 as this is still here with PHPUnit 5.
Actually, php class are loaded first on PHPUnit library (composer or .phar) before project classes.
@Seldaek I take permission to ping you as I'm not really sure it's a PHPUnit or composer issue.
This can break tests if the used class is not the same between PHPUnit and project.
I'll elaborate with 3 concrete cases. First of all, here is my
phpunit.xml
project file:With composer loaded PHPUnit binary
As you can see in the stack trace, the error occurred on the global vendor classes.
This error is "logic" because guzzle version differs between global and project vendors:
With phpunit.phar
This exception should not be thrown because my project is running under Symfony 2.8 full stack.
But PHPUnit 5 use
symfony/yaml
component that is bumped to 3.0 version.PHPUnit as a project dev dependency
If I require phpunit directly on my project and run it:
It works. But this is a workaround, not the solution. AFAIK, PHPUnit should be able to run standalone, at least with the .phar.
The text was updated successfully, but these errors were encountered: