Skip to content

Commit

Permalink
added test case for integer input in validator
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Oct 21, 2023
1 parent e0ed106 commit b22329b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Validator/ObjectExistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ public function testCanValidateWithSingleField(): void
$this->assertTrue($validator->isValid(['matchKey' => 'matchValue']));
}

public function testCanValidateWithIntegerId(): void
{
$repository = $this->createMock(ObjectRepository::class);

$repository
->expects($this->exactly(2))
->method('findOneBy')
->with(['matchKey' => 123])
->will($this->returnValue(new stdClass()));

$validator = new ObjectExists(['object_repository' => $repository, 'fields' => 'matchKey']);

$this->assertTrue($validator->isValid(123));
$this->assertTrue($validator->isValid(['matchKey' => 123]));
}

public function testCanValidateWithMultipleFields(): void
{
$repository = $this->createMock(ObjectRepository::class);
Expand Down

0 comments on commit b22329b

Please sign in to comment.