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

Breadcrumb

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

class ExpectationFailedException

Exception for expectations which failed their check.

The exception contains the error message and optionally a SebastianBergmann\Comparator\ComparisonFailure which is used to generate diff output of the failed expectations.

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

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

Hierarchy

  • class \PHPUnit\Framework\Exception extends \RuntimeException implements \PHPUnit\Exception
    • class \PHPUnit\Framework\AssertionFailedError extends \PHPUnit\Framework\Exception implements \PHPUnit\Framework\SelfDescribing
      • class \PHPUnit\Framework\ExpectationFailedException extends \PHPUnit\Framework\AssertionFailedError

Expanded class hierarchy of ExpectationFailedException

24 files declare their use of ExpectationFailedException
ComparisonFailureBuilder.php in vendor/phpunit/phpunit/src/Event/Value/ComparisonFailureBuilder.php
CompoundConstraintTestCase.php in vendor/symfony/validator/Test/CompoundConstraintTestCase.php
Constraint.php in vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php
ConstraintValidatorTestCase.php in vendor/symfony/validator/Test/ConstraintValidatorTestCase.php
InvokedAtLeastCount.php in vendor/phpunit/phpunit/src/Framework/MockObject/Runtime/Rule/InvokedAtLeastCount.php

... See full list

File

vendor/phpunit/phpunit/src/Framework/Exception/ExpectationFailedException.php, line 26

Namespace

PHPUnit\Framework
View source
final class ExpectationFailedException extends AssertionFailedError {
    protected ?ComparisonFailure $comparisonFailure = null;
    public function __construct(string $message, ?ComparisonFailure $comparisonFailure = null, ?Exception $previous = null) {
        $this->comparisonFailure = $comparisonFailure;
        parent::__construct($message, 0, $previous);
    }
    public function getComparisonFailure() : ?ComparisonFailure {
        return $this->comparisonFailure;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AssertionFailedError::toString public function Wrapper for getMessage() which is declared as final. Overrides SelfDescribing::toString
Exception::$serializableTrace protected property
Exception::getSerializableTrace public function Returns the serializable trace (without 'args').
Exception::__sleep public function
ExpectationFailedException::$comparisonFailure protected property
ExpectationFailedException::getComparisonFailure public function
ExpectationFailedException::__construct public function Overrides Exception::__construct

API Navigation

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