/
NumberComparisonOperatorsConstantConditionRuleTest.php
86 lines (71 loc) · 1.88 KB
/
NumberComparisonOperatorsConstantConditionRuleTest.php
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
75
76
77
78
79
80
81
82
83
84
85
86
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Comparison;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use const PHP_VERSION_ID;
/**
* @extends RuleTestCase<NumberComparisonOperatorsConstantConditionRule>
*/
class NumberComparisonOperatorsConstantConditionRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return new NumberComparisonOperatorsConstantConditionRule();
}
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/number-comparison-operators.php'], [
[
'Comparison operation "<=" between int<6, max> and 2 is always false.',
7,
],
[
'Comparison operation ">" between int<2, 4> and 8 is always false.',
13,
],
[
'Comparison operation "<" between int<min, 1> and 5 is always true.',
21,
],
]);
}
public function testBug2648(): void
{
$this->analyse([__DIR__ . '/data/bug-2648-rule.php'], []);
}
public function testBug2648Namespace(): void
{
$this->analyse([__DIR__ . '/data/bug-2648-namespace-rule.php'], []);
}
public function testBug5161(): void
{
if (PHP_VERSION_ID < 80000 && !self::$useStaticReflectionProvider) {
$this->markTestSkipped('Test requires PHP 8.0.');
}
$this->analyse([__DIR__ . '/data/bug-5161.php'], []);
}
public function testBug3310(): void
{
$this->analyse([__DIR__ . '/data/bug-3310.php'], []);
}
public function testBug3264(): void
{
$this->analyse([__DIR__ . '/data/bug-3264.php'], []);
}
public function testBug5656(): void
{
$this->analyse([__DIR__ . '/data/bug-5656.php'], []);
}
public function testBug3867(): void
{
$this->analyse([__DIR__ . '/data/bug-3867.php'], []);
}
public function testIntegerRangeGeneralization(): void
{
$this->analyse([__DIR__ . '/data/integer-range-generalization.php'], []);
}
public function testBug3153(): void
{
$this->analyse([__DIR__ . '/data/bug-3153.php'], []);
}
}