mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Improved ValidationException to avoid polluting the message with invalid data but keeping it on the string representation
This commit is contained in:
@@ -55,12 +55,9 @@ class ValidationExceptionTest extends TestCase
|
||||
'something' => ['baz', 'foo'],
|
||||
];
|
||||
$barValue = print_r(['baz', 'foo'], true);
|
||||
$expectedMessage = <<<EOT
|
||||
Provided data is not valid. These are the messages:
|
||||
|
||||
$expectedStringRepresentation = <<<EOT
|
||||
'foo' => bar
|
||||
'something' => {$barValue}
|
||||
|
||||
EOT;
|
||||
|
||||
$inputFilter = $this->prophesize(InputFilterInterface::class);
|
||||
@@ -69,9 +66,10 @@ EOT;
|
||||
$e = ValidationException::fromInputFilter($inputFilter->reveal());
|
||||
|
||||
$this->assertEquals($invalidData, $e->getInvalidElements());
|
||||
$this->assertEquals($expectedMessage, $e->getMessage());
|
||||
$this->assertEquals('Provided data is not valid', $e->getMessage());
|
||||
$this->assertEquals(-1, $e->getCode());
|
||||
$this->assertEquals($prev, $e->getPrevious());
|
||||
$this->assertStringContainsString($expectedStringRepresentation, (string) $e);
|
||||
$getMessages->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user