Skip to content

Commit daf978e

Browse files
committed
separated more named args tests
1 parent 9a0d039 commit daf978e

File tree

3 files changed

+59
-37
lines changed

3 files changed

+59
-37
lines changed

tests/Rules/PHPUnit/DataProviderDataRuleTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,49 +127,45 @@ public function testRule(): void
127127
'Parameter #1 $s of method DataProviderDataTest\TestInvalidVariadic2::testFoo() expects string, int given.',
128128
318,
129129
],
130-
[
131-
'Parameter $si of method DataProviderDataTest\TestArrayShapeIterable::testBar() expects int, string given.',
132-
332,
133-
],
134130
[
135131
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testBar() expects int, int|string given.',
136-
382,
132+
362,
137133
],
138134
[
139135
'Parameter #1 $i of method DataProviderDataTest\TestArrayIterator::testFoo() expects int, int|string given.',
140-
382,
136+
362,
141137
],
142138
[
143139
'Parameter #1 $s1 of method DataProviderDataTest\TestArrayIterator::testFooBar() expects string, int|string given.',
144-
382,
140+
362,
145141
],
146142
[
147143
'Parameter #1 $si of method DataProviderDataTest\TestWrongTypedIterable::testBar() expects int, string given.',
148-
400,
144+
380,
149145
],
150146
[
151147
'Parameter #2 $input of method DataProviderDataTest\AbstractBaseTest::testWithAttribute() expects string, int given.',
152-
427,
148+
407,
153149
],
154150
[
155151
'Parameter #2 $input of method DataProviderDataTest\AbstractBaseTest::testWithAttribute() expects string, false given.',
156-
431,
152+
411,
157153
],
158154
[
159155
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayUnionTypeReturnTest::testFoo() expects string, int given.',
160-
466,
156+
446,
161157
],
162158
[
163159
'Method DataProviderDataTest\ConstantArrayDifferentLengthUnionTypeReturnTest::testFoo() invoked with 3 parameters, 2 required.',
164-
504,
160+
484,
165161
],
166162
[
167163
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayDifferentLengthUnionTypeReturnTest::testFoo() expects string, int given.',
168-
504,
164+
484,
169165
],
170166
[
171167
'Parameter #2 $input of method DataProviderDataTest\ConstantArrayUnionWithDifferentValueTypeReturnTest::testFoo() expects string, int|string given.',
172-
537,
168+
517,
173169
],
174170
]);
175171
}
@@ -190,13 +186,17 @@ public function testRulePhp8(): void
190186
44
191187
],
192188
[
193-
'Unknown parameter $wrong in call to method DataProviderDataTestPhp8\TestArrayShapeIterable::testBar().',
189+
'Unknown parameter $wrong in call to method DataProviderDataTestPhp8\TestWrongOffsetNameArrayShapeIterable::testBar().',
194190
58
195191
],
196192
[
197-
'Missing parameter $si (int) in call to method DataProviderDataTestPhp8\TestArrayShapeIterable::testBar().',
193+
'Missing parameter $si (int) in call to method DataProviderDataTestPhp8\TestWrongOffsetNameArrayShapeIterable::testBar().',
198194
58
199195
],
196+
[
197+
'Parameter $si of method DataProviderDataTestPhp8\TestWrongTypeInArrayShapeIterable::testBar() expects int, string given.',
198+
79
199+
],
200200
]);
201201
}
202202

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function aProvider(): array
4646
}
4747

4848

49-
class TestArrayShapeIterable extends TestCase
49+
class TestWrongOffsetNameArrayShapeIterable extends TestCase
5050
{
5151
/** @dataProvider aProvider */
5252
public function testBar(int $si): void
@@ -65,3 +65,45 @@ public function data(): iterable
6565
{
6666
}
6767
}
68+
69+
70+
class TestWrongTypeInArrayShapeIterable extends TestCase
71+
{
72+
/** @dataProvider aProvider */
73+
public function testBar(int $si): void
74+
{
75+
}
76+
77+
public function aProvider(): iterable
78+
{
79+
return $this->data();
80+
}
81+
82+
/**
83+
* @return iterable<array{si: string}>
84+
*/
85+
public function data(): iterable
86+
{
87+
}
88+
}
89+
90+
91+
class TestValidArrayShapeIterable extends TestCase
92+
{
93+
/** @dataProvider aProvider */
94+
public function testBar(int $si): void
95+
{
96+
}
97+
98+
public function aProvider(): iterable
99+
{
100+
return $this->data();
101+
}
102+
103+
/**
104+
* @return iterable<array{si: int}>
105+
*/
106+
public function data(): iterable
107+
{
108+
}
109+
}

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -320,26 +320,6 @@ public function aProvider(): iterable
320320
}
321321
}
322322

323-
class TestArrayShapeIterable extends TestCase
324-
{
325-
/** @dataProvider aProvider */
326-
public function testBar(int $si): void
327-
{
328-
}
329-
330-
public function aProvider(): iterable
331-
{
332-
return $this->data();
333-
}
334-
335-
/**
336-
* @return iterable<array{si: string}>
337-
*/
338-
public function data(): iterable
339-
{
340-
}
341-
}
342-
343323
class TestTypedIterable extends TestCase
344324
{
345325
/** @dataProvider aProvider */

0 commit comments

Comments
 (0)