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

Breadcrumb

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

function JsonMatches::fail

Throws an exception for the given compared value and test description.

Throws

ExpectationFailedException

InvalidJsonException

Overrides Constraint::fail

File

vendor/phpunit/phpunit/src/Framework/Constraint/JsonMatches.php, line 71

Class

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

Namespace

PHPUnit\Framework\Constraint

Code

protected function fail(mixed $other, string $description, ?ComparisonFailure $comparisonFailure = null) : never {
    if ($comparisonFailure === null) {
        [
            $error,
            $recodedOther,
        ] = Json::canonicalize($other);
        if ($error) {
            parent::fail($other, $description);
        }
        [
            $error,
            $recodedValue,
        ] = Json::canonicalize($this->value);
        if ($error) {
            parent::fail($other, $description);
        }
        $comparisonFailure = new ComparisonFailure(json_decode($this->value), json_decode($other), Json::prettify($recodedValue), Json::prettify($recodedOther), 'Failed asserting that two json values are equal.');
    }
    parent::fail($other, $description, $comparisonFailure);
}
RSS feed
Powered by Drupal