-
-
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
Tests with DataProvider attribute throw error #5283
Comments
I cannot reproduce this:
|
Thanks for looking into this @sebastianbergmann! |
@sebastianbergmann Codedownload code phpunit-issue-master.zip To reproduce:I have a docker image uploaded to Docker Hub or you can build it manually:
Without
With
Strange that none of my other packages throw errors like that (if it's related to all attributes), PHPUnit 10 seems to be the only one with such an issue. I also have attributes used it that project, and they work just fine. Can't think of a reason... |
@PAXANDDOS I'm having the same issue (Win 11 - Docker WSL2). I'm wondering if it's an issue in PHPUnit or in Composer. I've created a tests/bootstrap.php file (the directory tests contain my tests) with this content, I can force register the classes (it's not working still because I haven't added all classes). <?php
/** @var \Composer\Autoload\ClassLoader $classLoader */
$classLoader = require 'vendor/autoload.php';
$classLoader->addClassMap([
\PHPUnit\Metadata\Metadata::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Metadata.php',
\PHPUnit\Metadata\Api\DataProvider::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Api/DataProvider.php',
\PHPUnit\Metadata\Parser\Registry::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Parser/Registry.php',
\PHPUnit\Metadata\Parser\CachingParser::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Parser/CachingParser.php',
\PHPUnit\Metadata\Parser\Parser::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Parser/Parser.php',
\PHPUnit\Metadata\Parser\ParserChain::class => __DIR__ . '/../vendor/phpunit/phpunit/src/Metadata/Parser/ParserChain.php',
]);
$classLoader->register(); But as the error now shows other classes that are not found in that directory, I started looking into Composer issues and found this: composer/composer#8808 (comment) Stating that there is a bug in WSL2 where the RecursiveDirectoryIterator returns an incomplete list... which, according to PHP, is a WSL2 bug: microsoft/WSL#5074 So this is not a PHPUnit bug, and for now there is no clear/easy solution to apply |
@Echron Thanks for the investigation! You definitely have shed light on this. As I can see on the WSL issue, it is mostly breaking PHP applications, which is a pity. And I guess the workaround for this issue would be.. run tests when the directory is not volumed. |
I had the same issue, updating |
Summary
When a test is using
DataProvider
attribute, it throws an error during execution.Current behavior
Following error is thrown during execution:
How to reproduce
Minimal reproduction test:
If we remove the attribute and function arguments, test will work just fine.
Expected behavior
Test is executed
Composer
PHPUnit is not wrapped in a framework, I just use packages from Symfony and CakePHP.
composer info | sort
The text was updated successfully, but these errors were encountered: