Skip to content

Commit 8473f87

Browse files
Extract method
1 parent 8dd3dac commit 8473f87

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

src/Metadata/Api/DataProvider.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -266,37 +266,15 @@ private function formatKey(int|string $key): string
266266
private function triggerWarningForMixingOfDataProviderAndTestWith(ReflectionMethod $method): void
267267
{
268268
Event\Facade::emitter()->testTriggeredPhpunitWarning(
269-
new TestMethod(
270-
$method->getDeclaringClass()->getName(),
271-
$method->getName(),
272-
$method->getFileName(),
273-
$method->getStartLine(),
274-
Event\Code\TestDoxBuilder::fromClassNameAndMethodName(
275-
$method->getDeclaringClass()->getName(),
276-
$method->getName(),
277-
),
278-
MetadataCollection::fromArray([]),
279-
Event\TestData\TestDataCollection::fromArray([]),
280-
),
269+
$this->testValueObject($method),
281270
'Mixing #[DataProvider*] and #[TestWith*] attributes is not supported, only the data provided by #[DataProvider*] will be used',
282271
);
283272
}
284273

285274
private function triggerWarningForArgumentCount(ReflectionMethod $method, string $key, string $label, int $numberOfValues, int $testMethodNumberOfParameters): void
286275
{
287276
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-
),
277+
$this->testValueObject($method),
300278
sprintf(
301279
'Data set %s provided by %s has more arguments (%d) than the test method accepts (%d)',
302280
$key,
@@ -306,4 +284,20 @@ private function triggerWarningForArgumentCount(ReflectionMethod $method, string
306284
),
307285
);
308286
}
287+
288+
private function testValueObject(ReflectionMethod $method): TestMethod
289+
{
290+
return new TestMethod(
291+
$method->getDeclaringClass()->getName(),
292+
$method->getName(),
293+
$method->getFileName(),
294+
$method->getStartLine(),
295+
Event\Code\TestDoxBuilder::fromClassNameAndMethodName(
296+
$method->getDeclaringClass()->getName(),
297+
$method->getName(),
298+
),
299+
MetadataCollection::fromArray([]),
300+
Event\TestData\TestDataCollection::fromArray([]),
301+
);
302+
}
309303
}

0 commit comments

Comments
 (0)