forked from phpstan/phpstan-phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributeRequiresPhpVersionRangeRuleTest.php
More file actions
74 lines (65 loc) · 1.67 KB
/
Copy pathAttributeRequiresPhpVersionRangeRuleTest.php
File metadata and controls
74 lines (65 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php declare(strict_types = 1);
namespace PHPStan\Rules\PHPUnit;
use PHPStan\Php\ConfiguredPhpVersionRangeHelper;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use PHPStan\Type\FileTypeMapper;
/**
* @extends RuleTestCase<AttributeRequiresPhpVersionRule>
*/
final class AttributeRequiresPhpVersionRangeRuleTest extends RuleTestCase
{
public function testPhpVersionMismatch(): void
{
$tip = 'PHP version for analysis inferred from NEON config phpVersion or composer.json requirements. Invoke PHPStan with -vvv to get more details.';
$this->analyse([__DIR__ . '/data/requires-php-version-mismatch.php'], [
[
'Version requirement < 7.0 does not match 8.2.0...8.4.0.',
20,
$tip,
],
[
'Version requirement ^5.0 does not match 8.2.0...8.4.0.',
28,
$tip,
],
[
'Version requirement ~5.0 does not match 8.2.0...8.4.0.',
36,
$tip,
],
[
'Version requirement 5.* does not match 8.2.0...8.4.0.',
44,
$tip,
],
[
'Version requirement 8.5.* does not match 8.2.0...8.4.0.',
76,
$tip,
],
]);
}
protected function getRule(): Rule
{
$phpunitVersion = new PHPUnitVersion(null, null);
return new AttributeRequiresPhpVersionRule(
new TestMethodsHelper(
self::getContainer()->getByType(FileTypeMapper::class),
$phpunitVersion,
),
new AttributeVersionRequirementHelper(
$phpunitVersion,
self::getContainer()->getByType(ConfiguredPhpVersionRangeHelper::class), // @phpstan-ignore phpstanApi.classConstant
false,
true,
),
);
}
public static function getAdditionalConfigFiles(): array
{
return [
__DIR__ . '/AttributeRequiresPhpVersionRangeRule.neon',
];
}
}