Skip to content

Commit

Permalink
test: add failing tests :-(
Browse files Browse the repository at this point in the history
  • Loading branch information
martenb committed Dec 11, 2023
1 parent e78b02d commit 13c23eb
Showing 1 changed file with 22 additions and 2 deletions.
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

0 comments on commit 13c23eb

Please sign in to comment.