From 80be8d2204631e5907deff98fa0f825ccbc0983c Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 2 Aug 2020 10:50:59 +0200 Subject: [PATCH 1/1] MDL-67673 phpunit: phpunit_constraint_object_is_equal_with_exceptions Constraints are now declared final, so we cannot extend them anymore. Hence, instead of extending PHPUnit\Framework\Constraint\IsEqual we are just wrapping it into our constraint. --- ...straint_object_is_equal_with_exceptions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php b/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php index 5fa1d25d4eb..b4685750d4b 100644 --- a/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php +++ b/lib/phpunit/classes/constraint_object_is_equal_with_exceptions.php @@ -32,7 +32,7 @@ * @copyright 2015 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framework\Constraint\IsEqual { +class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framework\Constraint\Constraint { /** * @var array $keys The list of exceptions. @@ -44,12 +44,17 @@ class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framewo */ protected $capturedvalue; + /** + * @var \PHPUnit\Framework\Constraint\IsEqual $isequal original constraint to be used internally. + */ + protected $isequal; + /** * Override constructor to capture value */ public function __construct($value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false) { - parent::__construct($value, $delta, $maxDepth, $canonicalize, $ignoreCase); + $this->isequal = new \PHPUnit\Framework\Constraint\IsEqual($value, $delta, $maxDepth, $canonicalize, $ignoreCase); $this->capturedvalue = $value; } @@ -93,8 +98,13 @@ class phpunit_constraint_object_is_equal_with_exceptions extends PHPUnit\Framewo } } - // Run the parent evaluation (isEqual). - return parent::evaluate($other, $description, $shouldreturnesult); + // Run the IsEqual evaluation. + return $this->isequal->evaluate($other, $description, $shouldreturnesult); + } + + // \PHPUnit\Framework\Constraint\IsEqual wrapping. + public function toString(): string { + return $this->isequal->toString(); } } -- 2.43.0