Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SymfonyValidator errors with typed properties #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Loading