@@ -91,26 +91,12 @@ public function providedData(string $className, string $methodName): ?array
91
91
}
92
92
93
93
if ($ testMethodIsNonVariadic && $ testMethodNumberOfParameters < count ($ value )) {
94
- Event \Facade::emitter ()->testTriggeredPhpunitWarning (
95
- new TestMethod (
96
- $ className ,
97
- $ methodName ,
98
- $ method ->getFileName (),
99
- $ method ->getStartLine (),
100
- Event \Code \TestDoxBuilder::fromClassNameAndMethodName (
101
- $ className ,
102
- $ methodName ,
103
- ),
104
- MetadataCollection::fromArray ([]),
105
- Event \TestData \TestDataCollection::fromArray ([]),
106
- ),
107
- sprintf (
108
- 'Data set %s provided by %s has more arguments (%d) than the test method accepts (%d) ' ,
109
- $ this ->formatKey ($ key ),
110
- $ providedData ->getProviderLabel (),
111
- count ($ value ),
112
- $ testMethodNumberOfParameters ,
113
- ),
94
+ $ this ->triggerWarningForArgumentCount (
95
+ $ method ,
96
+ $ this ->formatKey ($ key ),
97
+ $ providedData ->getProviderLabel (),
98
+ count ($ value ),
99
+ $ testMethodNumberOfParameters ,
114
100
);
115
101
}
116
102
}
@@ -295,4 +281,29 @@ private function triggerWarningForMixingOfDataProviderAndTestWith(ReflectionMeth
295
281
'Mixing #[DataProvider*] and #[TestWith*] attributes is not supported, only the data provided by #[DataProvider*] will be used ' ,
296
282
);
297
283
}
284
+
285
+ private function triggerWarningForArgumentCount (ReflectionMethod $ method , string $ key , string $ label , int $ numberOfValues , int $ testMethodNumberOfParameters ): void
286
+ {
287
+ Event \Facade::emitter ()->testTriggeredPhpunitWarning (
288
+ new TestMethod (
289
+ $ method ->getDeclaringClass ()->getName (),
290
+ $ method ->getName (),
291
+ $ method ->getFileName (),
292
+ $ method ->getStartLine (),
293
+ Event \Code \TestDoxBuilder::fromClassNameAndMethodName (
294
+ $ method ->getDeclaringClass ()->getName (),
295
+ $ method ->getName (),
296
+ ),
297
+ MetadataCollection::fromArray ([]),
298
+ Event \TestData \TestDataCollection::fromArray ([]),
299
+ ),
300
+ sprintf (
301
+ 'Data set %s provided by %s has more arguments (%d) than the test method accepts (%d) ' ,
302
+ $ key ,
303
+ $ label ,
304
+ $ numberOfValues ,
305
+ $ testMethodNumberOfParameters ,
306
+ ),
307
+ );
308
+ }
298
309
}
0 commit comments