-
- Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature/data-providerData ProvidersData Providersfeature/test-dependenciesIssues related to explicitly declared dependencies between testsIssues related to explicitly declared dependencies between teststype/bugSomething is brokenSomething is brokenversion/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12
Description
| Q | A |
|---|---|
| PHPUnit version | 11.5.2 |
| PHP version | 8.2.18 |
| Installation Method | Composer |
Summary
This is a follow-up to #5827 which was closed for a specific case ("mixture of associative and non-associative arrays") but the originally reported issue wasn't answered.
Current behavior
Test cases having both a dependency and a data provider don't work anymore in PHPUnit 11 using the attribute syntax. The same specification worked fine in PHPUnit 10 using the annotation syntax.
How to reproduce
Here's a minimal example with two test functions. The second one depends on the first one and uses a data provider. Running the test yields this error:
1) dependencyTest::testTwo with data set "case 1" ('') Error: Cannot use positional argument after named argument during unpacking Code example:
<?php class dependencyTest extends \PHPUnit\Framework\TestCase { public function testOne(): void { $this->assertEmpty([]); } #[\PHPUnit\Framework\Attributes\Depends('testOne')] #[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')] public function testTwo(string $example): void { $this->assertEmpty($example); } public static function dataProvider(): array { return [ 'case 1' => [ 'example' => '' ] ]; } }Expected behavior
I'd expect this to work because the data provider uses an associative array, i.e. the (single) argument IS a named one.
(Note: If I remove the dependency specification, the test runs successfully.)
DaBonse, vracini, Lokilein, adamaveray, khoi-storable and 1 more
Metadata
Metadata
Assignees
Labels
feature/data-providerData ProvidersData Providersfeature/test-dependenciesIssues related to explicitly declared dependencies between testsIssues related to explicitly declared dependencies between teststype/bugSomething is brokenSomething is brokenversion/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12