diff --git a/src/Validator/Exception/ValidationException.php b/src/Validator/Exception/ValidationException.php index 98117463ff1..720f1f26ca1 100644 --- a/src/Validator/Exception/ValidationException.php +++ b/src/Validator/Exception/ValidationException.php @@ -75,7 +75,7 @@ public function __construct(string|ConstraintViolationListInterface $message = ' if ($message instanceof ConstraintViolationListInterface) { $this->constraintViolationList = $message; - parent::__construct($code ?? $this->__toString(), $previous ?? 0, $errorTitle instanceof \Throwable ? $errorTitle : null); + parent::__construct($this->__toString(), $code ?? 0, $previous); return; } diff --git a/src/Validator/Tests/Exception/ValidationExceptionTest.php b/src/Validator/Tests/Exception/ValidationExceptionTest.php index 35afcd05cfa..09c77a198f2 100644 --- a/src/Validator/Tests/Exception/ValidationExceptionTest.php +++ b/src/Validator/Tests/Exception/ValidationExceptionTest.php @@ -39,4 +39,19 @@ public function testToString(): void TXT ), $e->__toString()); } + + public function testWithPrevious(): void + { + $previous = new \Exception(); + $e = new ValidationException(new ConstraintViolationList([ + new ConstraintViolation('message 1', '', [], '', '', 'invalid'), + ]), null, $previous); + $this->assertInstanceOf(\RuntimeException::class, $e); + + $this->assertSame(str_replace(\PHP_EOL, "\n", <<__toString()); + $this->assertSame($previous, $e->getPrevious()); + } }