Skip to content

Commit 3fc4e0e

Browse files
committed
separated php8 only tests
1 parent 807a35f commit 3fc4e0e

File tree

3 files changed

+85
-71
lines changed

3 files changed

+85
-71
lines changed

tests/Rules/PHPUnit/DataProviderDataRuleTest.php

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ protected function getRule(): Rule
4242

4343
public function testRule(): void
4444
{
45-
if (PHP_VERSION_ID < 80000) {
46-
self::markTestSkipped();
47-
}
48-
4945
$this->analyse([__DIR__ . '/data/data-provider-data.php'], [
5046
[
5147
'Parameter #2 $input of method DataProviderDataTest\FooTest::testWithAttribute() expects string, int given.',
@@ -99,97 +95,108 @@ public function testRule(): void
9995
'Parameter #2 $input of method DataProviderDataTest\UnionTypeReturnTest::testFoo() expects string, int given.',
10096
216,
10197
],
102-
[
103-
'Parameter $input of method DataProviderDataTest\NamedArgsInProvider::testFoo() expects string, int given.',
104-
255,
105-
],
106-
[
107-
'Parameter $input of method DataProviderDataTest\NamedArgsInProvider::testFoo() expects string, false given.',
108-
255,
109-
],
11098
[
11199
'Parameter #2 $input of method DataProviderDataTest\YieldFromExpr::testFoo() expects string, int given.',
112-
275,
100+
236,
113101
],
114102
[
115103
'Parameter #2 $input of method DataProviderDataTest\YieldFromExpr::testFoo() expects string, true given.',
116-
277,
104+
238,
117105
],
118106
[
119107
'Parameter #1 $si of method DataProviderDataTest\TestInvalidVariadic::testBar() expects int, string given.',
120-
334,
108+
295,
121109
],
122110
[
123111
'Parameter #1 $s of method DataProviderDataTest\TestInvalidVariadic::testFoo() expects string, int given.',
124-
335,
112+
296,
125113
],
126114
[
127115
'Parameter #1 $si of method DataProviderDataTest\TestInvalidVariadic2::testBar() expects int, string given.',
128-
356,
116+
317,
129117
],
130118
[
131119
'Parameter #2 ...$moreS of method DataProviderDataTest\TestInvalidVariadic2::testFoo() expects int, string given.',
132-
356,
120+
317,
133121
],
134122
[
135123
'Parameter #4 ...$moreS of method DataProviderDataTest\TestInvalidVariadic2::testFoo() expects int, string given.',
136-
356,
124+
317,
137125
],
138126
[
139127
'Parameter #1 $s of method DataProviderDataTest\TestInvalidVariadic2::testFoo() expects string, int given.',
140-
357,
128+
318,
141129
],
142130
[
143131
'Unknown parameter $foo in call to method DataProviderDataTest\TestArrayShapeIterable::testBar().',
144-
371,
132+
332,
145133
],
146134
[
147135
'Missing parameter $si (int) in call to method DataProviderDataTest\TestArrayShapeIterable::testBar().',
148-
371,
136+
332,
149137
],
150138
[
151139
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testBar() expects int, int|string given.',
152-
421,
140+
382,
153141
],
154142
[
155143
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testFoo() expects int, int|string given.',
156-
421,
144+
382,
157145
],
158146
[
159147
'Parameter #1 $s1 of method DataProviderDataTest\TestArrayIterator::testFooBar() expects string, int|string given.',
160-
421,
148+
382,
161149
],
162150
[
163151
'Parameter #1 $si of method DataProviderDataTest\TestWrongTypedIterable::testBar() expects int, string given.',
164-
439,
152+
400,
165153
],
166154
[
167155
'Parameter #2 $input of method DataProviderDataTest\AbstractBaseTest::testWithAttribute() expects string, int given.',
168-
466,
156+
427,
169157
],
170158
[
171159
'Parameter #2 $input of method DataProviderDataTest\AbstractBaseTest::testWithAttribute() expects string, false given.',
172-
470,
160+
431,
173161
],
174162
[
175163
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayUnionTypeReturnTest::testFoo() expects string, int given.',
176-
505,
164+
466,
177165
],
178166
[
179167
'Method DataProviderDataTest\ConstantArrayDifferentLengthUnionTypeReturnTest::testFoo() invoked with 3 parameters, 2 required.',
180-
543,
168+
504,
181169
],
182170
[
183171
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayDifferentLengthUnionTypeReturnTest::testFoo() expects string, int given.',
184-
543,
172+
504,
185173
],
186174
[
187175
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayUnionWithDifferentValueTypeReturnTest::testFoo() expects string, int|string given.',
188-
576,
176+
537,
189177
],
190178
]);
191179
}
192180

181+
public function testRulePhp8(): void
182+
{
183+
if (PHP_VERSION_ID < 80000) {
184+
self::markTestSkipped();
185+
}
186+
187+
$this->analyse([__DIR__ . '/data/data-provider-data-named.php'], [
188+
[
189+
'Parameter $input of method DataProviderDataTestPhp8\NamedArgsInProvider::testFoo() expects string, int given.',
190+
44
191+
],
192+
[
193+
'Parameter $input of method DataProviderDataTestPhp8\NamedArgsInProvider::testFoo() expects string, false given.',
194+
44
195+
],
196+
]);
197+
}
198+
199+
193200
public function testVariadicMethod(): void
194201
{
195202
$this->analyse([__DIR__ . '/data/data-provider-variadic-method.php'], [
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace DataProviderDataTestPhp8;
4+
5+
use PHPUnit\Framework\Attributes\DataProvider;
6+
use PHPUnit\Framework\Attributes\Test;
7+
use PHPUnit\Framework\TestCase;
8+
9+
10+
class NamedArgsInProvider extends TestCase
11+
{
12+
13+
/** @dataProvider aProvider */
14+
public function testFoo(string $expectedResult, string $input): void
15+
{
16+
}
17+
18+
public function aProvider(): array
19+
{
20+
$arr = [
21+
[
22+
"input" => 'Hello World',
23+
"expectedResult" => " Hello World \n"
24+
]
25+
];
26+
27+
if (rand(0,1)) {
28+
$arr = [
29+
[
30+
"input" => 123,
31+
"expectedResult" => " Hello World \n"
32+
]
33+
];
34+
}
35+
if (rand(0,1)) {
36+
$arr = [
37+
[
38+
"input" => false,
39+
"expectedResult" => " Hello World \n"
40+
]
41+
];
42+
}
43+
44+
return $arr;
45+
}
46+
}

tests/Rules/PHPUnit/data/data-provider-data.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -218,45 +218,6 @@ public function aProvider(): array
218218
}
219219

220220

221-
class NamedArgsInProvider extends TestCase
222-
{
223-
224-
/** @dataProvider aProvider */
225-
public function testFoo(string $expectedResult, string $input): void
226-
{
227-
}
228-
229-
public function aProvider(): array
230-
{
231-
$arr = [
232-
[
233-
"input" => 'Hello World',
234-
"expectedResult" => " Hello World \n"
235-
]
236-
];
237-
238-
if (rand(0,1)) {
239-
$arr = [
240-
[
241-
"input" => 123,
242-
"expectedResult" => " Hello World \n"
243-
]
244-
];
245-
}
246-
if (rand(0,1)) {
247-
$arr = [
248-
[
249-
"input" => false,
250-
"expectedResult" => " Hello World \n"
251-
]
252-
];
253-
}
254-
255-
return $arr;
256-
}
257-
}
258-
259-
260221
class YieldFromExpr extends TestCase
261222
{
262223

0 commit comments

Comments
 (0)