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

Breadcrumb

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

function Constraint::failureDescriptionInContext

Returns the description of the failure when this constraint appears in context of an $operator expression.

The purpose of this method is to provide meaningful failure description in context of operators such as LogicalNot. Native PHPUnit constraints are supported out of the box by LogicalNot, but externally developed ones had no way to provide correct messages in this context.

The method shall return empty string, when it does not handle customization by itself.

File

vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php, line 166

Class

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

Namespace

PHPUnit\Framework\Constraint

Code

protected function failureDescriptionInContext(Operator $operator, mixed $role, mixed $other) : string {
    $string = $this->toStringInContext($operator, $role);
    if ($string === '') {
        return '';
    }
    return Exporter::export($other, true) . ' ' . $string;
}

API Navigation

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