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

Breadcrumb

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

function TestCase::setData

@internal This method is not covered by the backward compatibility promise for PHPUnit

Throws

RuntimeException

File

vendor/phpunit/phpunit/src/Framework/TestCase.php, line 1095

Class

TestCase
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework

Code

public final function setData(int|string $dataName, array $data) : void {
    $this->dataName = $dataName;
    $this->data = $data;
    if (array_is_list($data)) {
        return;
    }
    try {
        $reflector = new ReflectionMethod($this, $this->name);
        $parameters = array_map(static fn(ReflectionParameter $parameter) => $parameter->name, $reflector->getParameters());
        foreach (array_keys($data) as $parameter) {
            if (is_string($parameter) && !in_array($parameter, $parameters, true)) {
                Event\Facade::emitter()->testTriggeredPhpunitDeprecation($this->valueObjectForEvents(), sprintf('Providing invalid named argument $%s for method %s::%s() is deprecated and will not be supported in PHPUnit 11.0.', $parameter, $this::class, $this->name));
            }
        }
        // @codeCoverageIgnoreStart
    } catch (ReflectionException $e) {
        throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
    }
    // @codeCoverageIgnoreEnd
}
RSS feed
Powered by Drupal