Skip to content

Commit 4b700e5

Browse files
committed
cleanup
1 parent bf1c958 commit 4b700e5

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

tests/Rules/PHPUnit/DataProviderDataRuleTest.php

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
use PHPStan\Rules\Rule;
99
use PHPStan\Testing\RuleTestCase;
1010
use PHPStan\Type\FileTypeMapper;
11+
use PHPUnit\Framework\Attributes\DataProvider;
1112
use const PHP_VERSION_ID;
1213

1314
/**
1415
* @extends RuleTestCase<CompositeRule>
1516
*/
1617
class DataProviderDataRuleTest extends RuleTestCase
1718
{
18-
private int $phpunitVersion;
19+
private ?int $phpunitVersion;
1920

2021
protected function getRule(): Rule
2122
{
@@ -272,36 +273,44 @@ public function testTrimmingArgs(): void
272273
]);
273274
}
274275

275-
public function testNamedArgumentsInDataProviders(): void
276+
static public function provideNamedArgumentVersions(): iterable
276277
{
277-
$this->phpunitVersion = 10;
278-
279-
$this->analyse([__DIR__ . '/data/data-provider-named-args.php'], [
280-
[
281-
'Parameter #1 $int of method DataProviderNamedArgs\FooTest::testFoo() expects int, string given.',
282-
26
283-
],
284-
[
285-
'Parameter #2 $string of method DataProviderNamedArgs\FooTest::testFoo() expects string, int given.',
286-
26
287-
],
288-
]);
278+
return [
279+
[null],
280+
[10],
281+
[11],
282+
];
289283
}
290284

291-
public function testNamedArgumentsInDataProvidersPhpUnit11OrNewer(): void
285+
/**
286+
* @dataProvider provideNamedArgumentVersions
287+
*/
288+
#[DataProvider('provideNamedArgumentVersions')]
289+
public function testNamedArgumentsInDataProviders(?int $phpunitVersion): void
292290
{
293-
if (PHP_VERSION_ID < 80000) {
294-
self::markTestSkipped('PHPUnit11 requires PHP 8.0.');
295-
}
291+
$this->phpunitVersion = $phpunitVersion;
296292

297-
$this->phpunitVersion = 11;
293+
if ($phpunitVersion >= 11) {
294+
$errors = [];
295+
$this->analyse([__DIR__ . '/data/data-provider-named-args.php'], [
296+
]);
297+
} else {
298+
$errors = [
299+
[
300+
'Parameter #1 $int of method DataProviderNamedArgs\FooTest::testFoo() expects int, string given.',
301+
26
302+
],
303+
[
304+
'Parameter #2 $string of method DataProviderNamedArgs\FooTest::testFoo() expects string, int given.',
305+
26
306+
],
307+
];
308+
}
298309

299-
$this->analyse([__DIR__ . '/data/data-provider-named-args.php'], [
300-
]);
310+
$this->analyse([__DIR__ . '/data/data-provider-named-args.php'], $errors);
301311
}
302312

303-
304-
/**
313+
/**
305314
* @return string[]
306315
*/
307316
public static function getAdditionalConfigFiles(): array

0 commit comments

Comments
 (0)