Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 26, 2022
1 parent a0c1364 commit f92aab7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/Rules/PHPUnit/ImpossibleCheckTypeMethodCallRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ public function testRule(): void
]);
}

public function testBug141(): void
{
$this->analyse([__DIR__ . '/data/bug-141.php'], [
[
"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.",
23,
],
]);
}

/**
* @return string[]
*/
Expand Down
53 changes: 53 additions & 0 deletions tests/Rules/PHPUnit/data/bug-141.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Bug141;

use PHPUnit\Framework\TestCase;

class Foo extends TestCase
{

/**
* @param array<'0.6.0'|'1.0.0'|'1.0.x-dev'|'1.1.x-dev'|'9999999-dev'|'dev-feature-b', true> $a
*/
public function doFoo(array $a): void
{
$this->assertEmpty($a);
}

/**
* @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
*/
public function doBar(array $a): void
{
$this->assertEmpty($a);
}

public function doBaz(): void
{
$expected = [
'0.6.0' => true,
'1.0.0' => true,
'1.0.x-dev' => true,
'1.1.x-dev' => true,
'dev-feature-b' => true,
'dev-feature/a-1.0-B' => true,
'dev-master' => true,
'9999999-dev' => true, // alias of dev-master
];

/** @var array<string> */
$packages = ['0.6.0', '1.0.0', '1'];

foreach ($packages as $version) {
if (isset($expected[$version])) {
unset($expected[$version]);
} else {
throw new \Exception('Unexpected version '.$version);
}
}

$this->assertEmpty($expected);
}

}

0 comments on commit f92aab7

Please sign in to comment.