Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DataProvider.php

function DataProvider::providedData

@psalm-param class-string $className @psalm-param non-empty-string $methodName

Throws

InvalidDataProviderException

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\Api

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal