Skip to content

Commit 9b093e3

Browse files
ntzmondrejmirtes
authored andcommitted
modernise tests
1 parent e2155ab commit 9b093e3

File tree

4 files changed

+64
-272
lines changed

4 files changed

+64
-272
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"require": {
99
"php": "^7.1 || ^8.0",
10-
"phpstan/phpstan": "^0.12.49"
10+
"phpstan/phpstan": "^0.12.85"
1111
},
1212
"require-dev": {
1313
"php-parallel-lint/php-parallel-lint": "^1.2",

tests/Type/WebMozartAssert/AssertTypeSpecifyingExtensionTest.php

Lines changed: 19 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -2,205 +2,37 @@
22

33
namespace PHPStan\Type\WebMozartAssert;
44

5-
use PHPStan\Rules\Rule;
5+
use PHPStan\Testing\TypeInferenceTestCase;
66

7-
/**
8-
* @extends \PHPStan\Testing\RuleTestCase<VariableTypeReportingRule>
9-
*/
10-
class AssertTypeSpecifyingExtensionTest extends \PHPStan\Testing\RuleTestCase
7+
class AssertTypeSpecifyingExtensionTest extends TypeInferenceTestCase
118
{
129

13-
protected function getRule(): Rule
10+
/**
11+
* @return iterable<mixed>
12+
*/
13+
public function dataFileAsserts(): iterable
1414
{
15-
return new VariableTypeReportingRule();
15+
yield from $this->gatherAssertTypes(__DIR__ . '/data/data.php');
1616
}
1717

1818
/**
19-
* @return \PHPStan\Type\StaticMethodTypeSpecifyingExtension[]
19+
* @dataProvider dataFileAsserts
20+
* @param string $assertType
21+
* @param string $file
22+
* @param mixed ...$args
2023
*/
21-
protected function getStaticMethodTypeSpecifyingExtensions(): array
24+
public function testFileAsserts(
25+
string $assertType,
26+
string $file,
27+
...$args
28+
): void
2229
{
23-
return [
24-
new AssertTypeSpecifyingExtension(),
25-
];
30+
$this->assertFileAsserts($assertType, $file, ...$args);
2631
}
2732

28-
public function testExtension(): void
33+
public static function getAdditionalConfigFiles(): array
2934
{
30-
$this->analyse([__DIR__ . '/data/data.php'], [
31-
[
32-
'Variable $a is: mixed',
33-
12,
34-
],
35-
[
36-
'Variable $a is: int',
37-
15,
38-
],
39-
[
40-
'Variable $b is: int|null',
41-
18,
42-
],
43-
[
44-
'Variable $c is: array<int>',
45-
21,
46-
],
47-
[
48-
'Variable $d is: iterable<int>',
49-
24,
50-
],
51-
[
52-
'Variable $e is: string',
53-
27,
54-
],
55-
[
56-
'Variable $f is: float',
57-
30,
58-
],
59-
[
60-
'Variable $g is: float|int|(string&numeric)',
61-
33,
62-
],
63-
[
64-
'Variable $h is: bool',
65-
36,
66-
],
67-
[
68-
'Variable $i is: bool|float|int|string',
69-
39,
70-
],
71-
[
72-
'Variable $j is: object',
73-
42,
74-
],
75-
[
76-
'Variable $k is: resource',
77-
45,
78-
],
79-
[
80-
'Variable $l is: callable(): mixed',
81-
48,
82-
],
83-
[
84-
'Variable $m is: array',
85-
51,
86-
],
87-
[
88-
'Variable $n is: array|Traversable',
89-
54,
90-
],
91-
[
92-
'Variable $o is: array|Countable',
93-
57,
94-
],
95-
[
96-
'Variable $p is: PHPStan\Type\WebMozartAssert\Foo',
97-
60,
98-
],
99-
[
100-
'Variable $q is: PHPStan\Type\WebMozartAssert\Foo',
101-
65,
102-
],
103-
[
104-
'Variable $r is: true',
105-
68,
106-
],
107-
[
108-
'Variable $s is: false',
109-
71,
110-
],
111-
[
112-
'Variable $t is: null',
113-
74,
114-
],
115-
[
116-
'Variable $u is: int',
117-
77,
118-
],
119-
[
120-
'Variable $v is: array<PHPStan\Type\WebMozartAssert\Foo>',
121-
82,
122-
],
123-
[
124-
'Variable $w is: array<int>',
125-
87,
126-
],
127-
[
128-
'Variable $x is: 1',
129-
90,
130-
],
131-
[
132-
'Variable $y is: -1|1',
133-
98,
134-
],
135-
[
136-
'Variable $y is: -1',
137-
100,
138-
],
139-
[
140-
'Variable $z is: array(1, -2|2, -3|3)',
141-
107,
142-
],
143-
[
144-
'Variable $aa is: class-string<PHPStan\Type\WebMozartAssert\Foo>|PHPStan\Type\WebMozartAssert\Foo',
145-
110,
146-
],
147-
[
148-
'Variable $ab is: array', // should array<PHPStan\Type\WebMozartAssert\Foo>
149-
113,
150-
],
151-
[
152-
'Variable $ac is: string',
153-
116,
154-
],
155-
[
156-
'Variable $ad is: float|int|(string&numeric)',
157-
119,
158-
],
159-
[
160-
'Variable $ae is: PHPStan\Type\WebMozartAssert\Baz',
161-
122,
162-
],
163-
[
164-
'Variable $af is: int',
165-
126,
166-
],
167-
[
168-
'Variable $things is: array(\'foo\' => string, ?\'bar\' => string)',
169-
131,
170-
],
171-
[
172-
'Variable $ag is: class-string',
173-
134,
174-
],
175-
[
176-
'Variable $ah is: array<stdClass>',
177-
141,
178-
],
179-
[
180-
'Variable $ai is: array',
181-
144,
182-
],
183-
[
184-
'Variable $ai is: array<string>',
185-
146,
186-
],
187-
[
188-
'Variable $ak is: int',
189-
152,
190-
],
191-
[
192-
'Variable $al is: \'bar\'|\'foo\'',
193-
155,
194-
],
195-
[
196-
'Variable $am is: \'bar\'|\'foo\'|null',
197-
158,
198-
],
199-
[
200-
'Variable $an is: 1|2',
201-
161,
202-
],
203-
]);
35+
return [__DIR__ . '/../../../extension.neon'];
20436
}
20537

20638
}

tests/Type/WebMozartAssert/VariableTypeReportingRule.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)