Skip to content

Commit beb34cb

Browse files
herndlmondrejmirtes
authored andcommitted
Extract bleeding edge tests
1 parent 8213017 commit beb34cb

File tree

4 files changed

+70
-5
lines changed

4 files changed

+70
-5
lines changed

tests/Type/WebMozartAssert/AssertTypeSpecifyingExtensionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static function getAdditionalConfigFiles(): array
3737
{
3838
return [
3939
__DIR__ . '/../../../extension.neon',
40-
'phar://' . __DIR__ . '/../../../vendor/phpstan/phpstan/phpstan.phar/conf/bleedingEdge.neon',
4140
];
4241
}
4342

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Type\WebMozartAssert;
4+
5+
use PHPStan\Testing\TypeInferenceTestCase;
6+
7+
class AssertTypeSpecifyingExtensionTestBleedingEdge extends TypeInferenceTestCase
8+
{
9+
10+
/** @return iterable<mixed> */
11+
public function dataFileAsserts(): iterable
12+
{
13+
yield from $this->gatherAssertTypes(__DIR__ . '/data/array-bleeding-edge.php');
14+
}
15+
16+
/**
17+
* @dataProvider dataFileAsserts
18+
* @param mixed ...$args
19+
*/
20+
public function testFileAsserts(
21+
string $assertType,
22+
string $file,
23+
...$args
24+
): void
25+
{
26+
$this->assertFileAsserts($assertType, $file, ...$args);
27+
}
28+
29+
public static function getAdditionalConfigFiles(): array
30+
{
31+
return [
32+
__DIR__ . '/../../../extension.neon',
33+
'phar://' . __DIR__ . '/../../../vendor/phpstan/phpstan/phpstan.phar/conf/bleedingEdge.neon',
34+
];
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace PHPStan\Type\WebMozartAssert;
4+
5+
use Webmozart\Assert\Assert;
6+
use function PHPStan\Testing\assertType;
7+
8+
class ArrayBleedingEdgeTest
9+
{
10+
11+
public function isList($a, $b): void
12+
{
13+
Assert::isList($a);
14+
assertType('list<mixed>', $a);
15+
16+
Assert::nullOrIsList($b);
17+
assertType('list<mixed>|null', $b);
18+
}
19+
20+
public function isNonEmptyList($a, $b): void
21+
{
22+
Assert::isNonEmptyList($a);
23+
assertType('non-empty-list<mixed>', $a);
24+
25+
Assert::nullOrIsNonEmptyList($b);
26+
assertType('non-empty-list<mixed>|null', $b);
27+
}
28+
29+
}

tests/Type/WebMozartAssert/data/array.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ public function countBetween(array $a, array $b, array $c, array $d): void
101101
public function isList($a, $b): void
102102
{
103103
Assert::isList($a);
104-
assertType('list<mixed>', $a);
104+
assertType('array<int, mixed>', $a);
105105

106106
Assert::nullOrIsList($b);
107-
assertType('list<mixed>|null', $b);
107+
assertType('array<int, mixed>|null', $b);
108108
}
109109

110110
public function isNonEmptyList($a, $b): void
111111
{
112112
Assert::isNonEmptyList($a);
113-
assertType('non-empty-list<mixed>', $a);
113+
assertType('non-empty-array<int, mixed>', $a);
114114

115115
Assert::nullOrIsNonEmptyList($b);
116-
assertType('non-empty-list<mixed>|null', $b);
116+
assertType('non-empty-array<int, mixed>|null', $b);
117117
}
118118

119119
public function isMap($a, $b): void

0 commit comments

Comments
 (0)