From 13c23eb72029c19de697ab97bd0f916ef9ac47c6 Mon Sep 17 00:00:00 2001 From: Martin Brettschneider Date: Mon, 11 Dec 2023 19:15:24 +0100 Subject: [PATCH] test: add failing tests :-( --- .../Mapping/Validator/SymfonyValidator.phpt | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/Cases/Core/Mapping/Validator/SymfonyValidator.phpt b/tests/Cases/Core/Mapping/Validator/SymfonyValidator.phpt index b9eb36b..7eb983e 100644 --- a/tests/Cases/Core/Mapping/Validator/SymfonyValidator.phpt +++ b/tests/Cases/Core/Mapping/Validator/SymfonyValidator.phpt @@ -23,9 +23,19 @@ Toolkit::test(function (): void { $entity = (new SimpleEntity())->factory(['id' => 1, 'typedId' => 'foo']); - Assert::exception(static function () use ($entity, $validator): void { + $e = Assert::exception(static function () use ($entity, $validator): void { $validator->validate($entity); }, ValidationException::class); + + assert($e instanceof ValidationException); + + Assert::same([ + 'validation' => [ + 'typedId' => [ + 'This value should be of type integer.', + ], + ], + ], $e->getContext()); }); // Without annotation reader @@ -34,10 +44,20 @@ Toolkit::test(function (): void { $entity = (new SimpleEntity())->factory(['id' => null, 'typedId' => 'foo']); - Assert::exception(static function () use ($entity, $validator): void { + $e = Assert::exception(static function () use ($entity, $validator): void { $validator->validate($entity); }, ValidationException::class); + assert($e instanceof ValidationException); + + Assert::same([ + 'validation' => [ + 'typedId' => [ + 'This value should be of type integer.', + ], + ], + ], $e->getContext()); + $entity = (new SimpleEntity())->factory(['id' => null, 'typedId' => 1]); Assert::noError(static function () use ($entity, $validator): void {