Skip to content

Commit dc76f12

Browse files
committed
Test quality of life checks for assertSuperType
1 parent c0f2e9e commit dc76f12

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

tests/PHPStan/Testing/TypeInferenceTestCaseTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public static function dataFileAssertionFailedErrors(): iterable
3737
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-type-missing-namespace.php'),
3838
),
3939
];
40+
yield [
41+
__DIR__ . '/data/assert-super-type-missing-namespace.php',
42+
sprintf(
43+
'Missing use statement for assertSuperType() in %s on line 6.',
44+
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-super-type-missing-namespace.php'),
45+
),
46+
];
4047
yield [
4148
__DIR__ . '/data/assert-certainty-wrong-namespace.php',
4249
sprintf(
@@ -58,6 +65,13 @@ public static function dataFileAssertionFailedErrors(): iterable
5865
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-type-wrong-namespace.php'),
5966
),
6067
];
68+
yield [
69+
__DIR__ . '/data/assert-super-type-wrong-namespace.php',
70+
sprintf(
71+
'Function PHPStan\Testing\assertSuperType imported with wrong namespace SomeWrong\Namespace\assertSuperType called in %s on line 8.',
72+
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-super-type-wrong-namespace.php'),
73+
),
74+
];
6175
yield [
6276
__DIR__ . '/data/assert-certainty-case-insensitive.php',
6377
sprintf(
@@ -79,6 +93,13 @@ public static function dataFileAssertionFailedErrors(): iterable
7993
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-type-case-insensitive.php'),
8094
),
8195
];
96+
yield [
97+
__DIR__ . '/data/assert-super-type-case-insensitive.php',
98+
sprintf(
99+
'Missing use statement for assertSuperTYPe() in %s on line 6.',
100+
$fileHelper->normalizePath('tests/PHPStan/Testing/data/assert-super-type-case-insensitive.php'),
101+
),
102+
];
82103
}
83104

84105
#[DataProvider('dataFileAssertionFailedErrors')]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php // lint >= 8.0
2+
3+
namespace MissingTypeCaseSensitive;
4+
5+
function doFoo(string $s) {
6+
assertSuperTYPe('string', $s);
7+
}
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php // lint >= 8.0
2+
3+
namespace MissingAssertTypeNamespace;
4+
5+
function doFoo(string $s) {
6+
assertSuperType('string', $s);
7+
}
8+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php // lint >= 8.0
2+
3+
namespace WrongAssertTypeNamespace;
4+
5+
use function SomeWrong\Namespace\assertSuperType;
6+
7+
function doFoo(string $s) {
8+
assertSuperType('string', $s);
9+
}
10+

0 commit comments

Comments
 (0)