-
-
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
Test with dependencies and data provider fails #5827
Comments
Thank you for your report. Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue. |
Did this work with PHPUnit 11.1.2 and now no longer works with PHPUnit 11.1.3? |
In my case, this error occurs if the data provider method returns an array with a mixture of associative and non-associative arrays. Example: <?php declare(strict_types=1);
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
final class DataProviderTestCase extends TestCase
{
#[DataProvider('workingProvider')]
public function testUseWorkingProvider(string $from, int $expected): void
{
$this->assertSame('january', $from);
$this->assertSame(4, $expected);
}
public static function workingProvider(): array
{
return [
[ 'from' => 'january', 'expected' => 4 ],
];
}
#[DataProvider('notWorkingProvider')]
public function testUseNotWorking(string $from, int $expected): void
{
$this->assertSame('january', $from);
$this->assertSame(4, $expected);
}
public static function notWorkingProvider(): array
{
return [
[ 'from' => 'january', 4 ],
];
}
} My output:
And for 11.1.2 it also doesn't work:
|
Summary
If test case has dependency on other test and has data provider, than it will fail to pass arguments with error
How to reproduce
Create following test case
Thrown in
PHPUnit\Framework\TestCase::runTest@1173
Expected behavior
Test method is called correctly
Possible solution
Do not merge arguments to one array
The text was updated successfully, but these errors were encountered: