Skip to content

Commit f92aab7

Browse files
committed
Regression test
1 parent a0c1364 commit f92aab7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

tests/Rules/PHPUnit/ImpossibleCheckTypeMethodCallRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ public function testRule(): void
3131
]);
3232
}
3333

34+
public function testBug141(): void
35+
{
36+
$this->analyse([__DIR__ . '/data/bug-141.php'], [
37+
[
38+
"Call to method PHPUnit\Framework\Assert::assertEmpty() with non-empty-array<'0.6.0'|'1.0.0'|'1.0.x-dev'|'1.1.x-dev'|'9999999-dev'|'dev-feature-b', true> will always evaluate to false.",
39+
23,
40+
],
41+
]);
42+
}
43+
3444
/**
3545
* @return string[]
3646
*/

tests/Rules/PHPUnit/data/bug-141.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Bug141;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
class Foo extends TestCase
8+
{
9+
10+
/**
11+
* @param array<'0.6.0'|'1.0.0'|'1.0.x-dev'|'1.1.x-dev'|'9999999-dev'|'dev-feature-b', true> $a
12+
*/
13+
public function doFoo(array $a): void
14+
{
15+
$this->assertEmpty($a);
16+
}
17+
18+
/**
19+
* @param non-empty-array<'0.6.0'|'1.0.0'|'1.0.x-dev'|'1.1.x-dev'|'9999999-dev'|'dev-feature-b', true> $a
20+
*/
21+
public function doBar(array $a): void
22+
{
23+
$this->assertEmpty($a);
24+
}
25+
26+
public function doBaz(): void
27+
{
28+
$expected = [
29+
'0.6.0' => true,
30+
'1.0.0' => true,
31+
'1.0.x-dev' => true,
32+
'1.1.x-dev' => true,
33+
'dev-feature-b' => true,
34+
'dev-feature/a-1.0-B' => true,
35+
'dev-master' => true,
36+
'9999999-dev' => true, // alias of dev-master
37+
];
38+
39+
/** @var array<string> */
40+
$packages = ['0.6.0', '1.0.0', '1'];
41+
42+
foreach ($packages as $version) {
43+
if (isset($expected[$version])) {
44+
unset($expected[$version]);
45+
} else {
46+
throw new \Exception('Unexpected version '.$version);
47+
}
48+
}
49+
50+
$this->assertEmpty($expected);
51+
}
52+
53+
}

0 commit comments

Comments
 (0)