Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions tests/Cases/Core/Mapping/Validator/SymfonyValidator.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down