Skip to content

Commit e6c97d3

Browse files
committed
added unit test
1 parent 45eb043 commit e6c97d3

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/Php/PhpVersions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(
2020

2121
public function producesWarningForFinalPrivateMethods(): TrinaryLogic
2222
{
23-
return $this->phpVersions->isSuperTypeOf(IntegerRangeType::fromInterval(80000, null))->result;
23+
return IntegerRangeType::fromInterval(80000, null)->isSuperTypeOf($this->phpVersions)->result;
2424
}
2525

2626
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Php;
4+
5+
use PHPStan\TrinaryLogic;
6+
use PHPStan\Type\IntegerRangeType;
7+
use PHPStan\Type\Type;
8+
use PHPStan\Type\Constant\ConstantIntegerType;
9+
use PHPStan\Type\UnionType;
10+
use PHPUnit\Framework\TestCase;
11+
12+
class PhpVersionsTest extends TestCase
13+
{
14+
/**
15+
* @dataProvider dataProducesWarningForFinalPrivateMethods
16+
*/
17+
public function testProducesWarningForFinalPrivateMethods(TrinaryLogic $expected, Type $versionType ) {
18+
$phpVersions = new PhpVersions($versionType);
19+
$this->assertSame(
20+
$expected->describe(),
21+
$phpVersions->producesWarningForFinalPrivateMethods()->describe()
22+
);
23+
}
24+
25+
public function dataProducesWarningForFinalPrivateMethods(): iterable {
26+
yield [
27+
TrinaryLogic::createNo(),
28+
new ConstantIntegerType(70400),
29+
];
30+
31+
yield [
32+
TrinaryLogic::createYes(),
33+
new ConstantIntegerType(80000),
34+
];
35+
36+
yield [
37+
TrinaryLogic::createYes(),
38+
new ConstantIntegerType(80100),
39+
];
40+
41+
yield [
42+
TrinaryLogic::createYes(),
43+
IntegerRangeType::fromInterval(80000, null)
44+
];
45+
46+
yield [
47+
TrinaryLogic::createMaybe(),
48+
IntegerRangeType::fromInterval(null, 80000)
49+
];
50+
51+
yield [
52+
TrinaryLogic::createNo(),
53+
IntegerRangeType::fromInterval(70200, 70400)
54+
];
55+
56+
yield [
57+
TrinaryLogic::createMaybe(),
58+
new UnionType([
59+
IntegerRangeType::fromInterval(70200, 70400),
60+
IntegerRangeType::fromInterval(80200, 80400),
61+
])
62+
];
63+
}
64+
}

0 commit comments

Comments
 (0)