Skip to content

Commit c9f5aae

Browse files
committed
expect no errors on single pph versions
1 parent ff63a08 commit c9f5aae

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
phpVersion: 80210
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Rules\PHPUnit;
4+
5+
use PHPStan\Php\ConfiguredPhpVersionRangeHelper;
6+
use PHPStan\Rules\PHPUnit\AttributeRequiresPhpVersionRule;
7+
use PHPStan\Rules\PHPUnit\AttributeVersionRequirementHelper;
8+
use PHPStan\Rules\PHPUnit\PHPUnitVersion;
9+
use PHPStan\Rules\PHPUnit\TestMethodsHelper;
10+
use PHPStan\Rules\Rule;
11+
use PHPStan\Testing\RuleTestCase;
12+
use PHPStan\Type\FileTypeMapper;
13+
14+
/**
15+
* @extends RuleTestCase<AttributeRequiresPhpVersionRule>
16+
*/
17+
final class AttributeRequiresSinglePhpVersionRuleTest extends RuleTestCase
18+
{
19+
20+
public function testPhpVersionMismatch(): void
21+
{
22+
$this->analyse([__DIR__ . '/data/requires-php-version-mismatch.php'], []);
23+
}
24+
25+
protected function getRule(): Rule
26+
{
27+
$phpunitVersion = new PHPUnitVersion(null, null);
28+
29+
return new AttributeRequiresPhpVersionRule(
30+
new TestMethodsHelper(
31+
self::getContainer()->getByType(FileTypeMapper::class),
32+
$phpunitVersion,
33+
),
34+
new AttributeVersionRequirementHelper(
35+
$phpunitVersion,
36+
self::getContainer()->getByType(ConfiguredPhpVersionRangeHelper::class), // @phpstan-ignore phpstanApi.classConstant
37+
false,
38+
true,
39+
),
40+
);
41+
}
42+
43+
public static function getAdditionalConfigFiles(): array
44+
{
45+
return [
46+
__DIR__ . '/AttributeRequiresSinglePhpVersionRule.neon',
47+
];
48+
}
49+
50+
}

0 commit comments

Comments
 (0)