function DataProvider::providedData
@psalm-param class-string $className @psalm-param non-empty-string $methodName
Throws
File
-
vendor/
phpunit/ phpunit/ src/ Metadata/ Api/ DataProvider.php, line 59
Class
- DataProvider
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\Metadata\ApiCode
public function providedData(string $className, string $methodName) : ?array {
$dataProvider = MetadataRegistry::parser()->forMethod($className, $methodName)
->isDataProvider();
$testWith = MetadataRegistry::parser()->forMethod($className, $methodName)
->isTestWith();
if ($dataProvider->isEmpty() && $testWith->isEmpty()) {
return $this->dataProvidedByTestWithAnnotation($className, $methodName);
}
if ($dataProvider->isNotEmpty()) {
$data = $this->dataProvidedByMethods($className, $methodName, $dataProvider);
}
else {
$data = $this->dataProvidedByMetadata($testWith);
}
if ($data === []) {
throw new InvalidDataProviderException('Empty data set provided by data provider');
}
foreach ($data as $key => $value) {
if (!is_array($value)) {
throw new InvalidDataProviderException(sprintf('Data set %s is invalid', is_int($key) ? '#' . $key : '"' . $key . '"'));
}
}
return $data;
}