| 148 |
lars |
1 |
<?php declare(strict_types=1);
|
|
|
2 |
/*
|
|
|
3 |
* This file is part of PHPUnit.
|
|
|
4 |
*
|
|
|
5 |
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
namespace PHPUnit\Framework;
|
|
|
11 |
|
|
|
12 |
use Exception;
|
|
|
13 |
use SebastianBergmann\Comparator\ComparisonFailure;
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* Exception for expectations which failed their check.
|
|
|
17 |
*
|
|
|
18 |
* The exception contains the error message and optionally a
|
|
|
19 |
* SebastianBergmann\Comparator\ComparisonFailure which is used to
|
|
|
20 |
* generate diff output of the failed expectations.
|
|
|
21 |
*
|
|
|
22 |
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
|
|
23 |
*/
|
|
|
24 |
final class ExpectationFailedException extends AssertionFailedError
|
|
|
25 |
{
|
|
|
26 |
/**
|
|
|
27 |
* @var ComparisonFailure
|
|
|
28 |
*/
|
|
|
29 |
protected $comparisonFailure;
|
|
|
30 |
|
|
|
31 |
public function __construct(string $message, ComparisonFailure $comparisonFailure = null, Exception $previous = null)
|
|
|
32 |
{
|
|
|
33 |
$this->comparisonFailure = $comparisonFailure;
|
|
|
34 |
|
|
|
35 |
parent::__construct($message, 0, $previous);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
public function getComparisonFailure(): ?ComparisonFailure
|
|
|
39 |
{
|
|
|
40 |
return $this->comparisonFailure;
|
|
|
41 |
}
|
|
|
42 |
}
|