phpunit: Strange error in tests after update to phpunit 6
One of my tests was green in 5.7 now is red 😦 . In that test I used $this->callback() and error is
PHP Fatal error: Cannot use PHPUnit\Framework\Exception as Exception because the name is already in use in <pathToMyProject>\vendor\phpunit\phpunit\src\Framework\Constraint\Callback.php on line 12
Its strange 😃. When I removed line:
use PHPUnit\Framework\Exception;
from that file all tests passed.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (6 by maintainers)
Links to this issue
Commits related to this issue
- Hopefully fix #2460 — committed to sebastianbergmann/phpunit by sebastianbergmann 7 years ago
- Require phpunit ^6.0.3 To get rid of https://github.com/sebastianbergmann/phpunit/issues/2460 which hits this project on Travis CI. — committed to stesie/phpcs-doctrine-annotation-rules by stesie 7 years ago
For phpunit 6.5.5 version the problem exists.
$ phpunit
PHP Warning: is_dir() expects parameter 1 to be a valid path, object given in /usr/share/php/PHPUnit/Runner/BaseTestRunner.php on line 56 PHP Recoverable fatal error: Object of class PHPUnit\Framework\TestSuite could not be converted to string in /usr/share/php/PHPUnit/Runner/StandardTestSuiteLoader.php on line 32
$ phpunit --version PHPUnit 6.5.5 by Sebastian Bergmann and contributors.
Can you please check whether d109afe3e4bf2f5e176a9baa95f6cf015135071e solves the problem?
I can confirm this issue with PHP 7.0.15 on Ubuntu 16.04 though mine is not exactly the same. I had PHPUnit 5.1.3 installed localy and version 6.2.1 using composer. When running tests with phpunit 6.2.1 and --teamcity option (used by PHPStorm), I got the following error:
If I remove local PHPUnit 5.1.3 it works fine.