-
Notifications
You must be signed in to change notification settings - Fork 438
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
TestCase compatibility with recent versions of phpunit #767
Comments
Here's the error I have : $ composer req --dev phpunit/phpunit
Using version ^9.1 for phpunit/phpunit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 30 installs, 0 updates, 0 removals
- Installing sebastian/version (3.0.0): Downloading (100%)
- Installing sebastian/type (2.0.0): Downloading (100%)
- Installing sebastian/resource-operations (3.0.0): Downloading (100%)
- Installing sebastian/recursion-context (4.0.0): Downloading (100%)
- Installing sebastian/object-reflector (2.0.0): Downloading (100%)
- Installing sebastian/object-enumerator (4.0.0): Downloading (100%)
- Installing sebastian/global-state (4.0.0): Downloading (100%)
- Installing sebastian/exporter (4.0.0): Downloading (100%)
- Installing sebastian/environment (5.1.0): Downloading (100%)
- Installing sebastian/diff (4.0.1): Downloading (100%)
- Installing sebastian/comparator (4.0.0): Downloading (100%)
- Installing sebastian/code-unit (1.0.2): Downloading (100%)
- Installing phpunit/php-timer (3.1.4): Downloading (100%)
- Installing phpunit/php-text-template (2.0.0): Downloading (100%)
- Installing phpunit/php-invoker (3.0.0): Downloading (100%)
- Installing phpunit/php-file-iterator (3.0.1): Downloading (100%)
- Installing theseer/tokenizer (1.1.3): Downloading (100%)
- Installing sebastian/code-unit-reverse-lookup (2.0.0): Downloading (100%)
- Installing phpunit/php-token-stream (4.0.1): Downloading (100%)
- Installing phpunit/php-code-coverage (8.0.1): Downloading (100%)
- Installing doctrine/instantiator (1.3.0): Downloading (100%)
- Installing phpdocumentor/reflection-common (2.1.0): Downloading (100%)
- Installing webmozart/assert (1.8.0): Downloading (100%)
- Installing phpdocumentor/type-resolver (1.1.0): Downloading (100%)
- Installing phpdocumentor/reflection-docblock (5.1.0): Downloading (100%)
- Installing phpspec/prophecy (v1.10.3): Downloading (100%)
- Installing phar-io/version (2.0.1): Downloading (100%)
- Installing phar-io/manifest (1.0.3): Downloading (100%)
- Installing myclabs/deep-copy (1.9.5): Downloading (100%)
- Installing phpunit/phpunit (9.1.4): Downloading (100%)
sebastian/global-state suggests installing ext-uopz (*)
sebastian/environment suggests installing ext-posix (*)
phpunit/phpunit suggests installing ext-soap (*)
Writing lock file
Generating autoload files
21 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
$ vendor/bin/phpunit tests
PHP Fatal error: Declaration of GrumPHP\Test\Task\AbstractTaskTestCase::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void in /home/talus/dev/grumphp/junk-checker/vendor/phpro/grumphp/src/Test/Task/AbstractTaskTestCase.php on line 33
PHP Stack trace:
PHP 1. {main}() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/phpunit:0
PHP 2. PHPUnit\TextUI\Command::main() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/phpunit:61
PHP 3. PHPUnit\TextUI\Command->run() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/TextUI/Command.php:68
PHP 4. PHPUnit\TextUI\TestRunner->getTest() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/TextUI/Command.php:85
PHP 5. PHPUnit\Framework\TestSuite->addTestFiles() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:94
PHP 6. PHPUnit\Framework\TestSuite->addTestFile() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/Framework/TestSuite.php:494
PHP 7. PHPUnit\Util\FileLoader::checkAndLoad() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/Framework/TestSuite.php:366
PHP 8. PHPUnit\Util\FileLoader::load() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/Util/FileLoader.php:44
PHP 9. include_once() /home/talus/dev/grumphp/junk-checker/vendor/phpunit/phpunit/src/Util/FileLoader.php:56
PHP 10. spl_autoload_call() /home/talus/dev/grumphp/junk-checker/tests/JunkCheckTest.php:12
PHP 11. Composer\Autoload\ClassLoader->loadClass() /home/talus/dev/grumphp/junk-checker/tests/JunkCheckTest.php:12
PHP 12. Composer\Autoload\includeFile() /home/talus/dev/grumphp/junk-checker/vendor/composer/ClassLoader.php:322
PHP 13. include() /home/talus/dev/grumphp/junk-checker/vendor/composer/ClassLoader.php:444 There's probably more though, as phpunit's author likes to break things on majors (as he should). :} |
Agree, it is probably best to upgrade it! |
Should we upgrade it or use the bridge then ? As the bridge patches phpunit in ways so a testcase can stay compatible with phpunit 6 / 7 / 8 / 9 (I think) |
I would avoid switching to the bridge. |
For the tests environment yes, but don't forget you're providing a base test case for tasks, which may want to add tests. That's why the compatibility with multiple phpunit versions can be interesting. :} Even though if it were up to me, I'd go for the latest each time :P |
Agree; Most of the time a custom task is added in an extension with very little scope. Maybe if you create an application specific task, it can be a bit blocking; But I don't know if it is being used like that. |
To be honest, I'm not quite sure either. Maybe a first step would be to just support latest phpunit (if it's in the php version range, as I know the author likes to bump to latest php or almost on each major), and see how it plays out later ? Once again, I'm not against that (far from it). As long as we're not stuck on an older version. :D |
True, the future will tell! Lets settle for the highest phpunit version for now then! |
As a task developper, I'd like to use the
AbstractTaskTestCase
class to make my tests on the tasks.The thing is, it doesn't seem that the classes
AbstractTaskTestCase
(and probably the external one) are supporting phpunit > 7, especially with the setUp method that changed its signature I think it was on PHPUnit 8, and some assert helpers have been dropped (don't know which ones though).Maybe using symfony's bridge would be an option ?
The text was updated successfully, but these errors were encountered: