Skip to content

Commit

Permalink
Add type returned
Browse files Browse the repository at this point in the history
  • Loading branch information
idmarinas committed Dec 27, 2023
1 parent 1c85a12 commit f37eb76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 7 additions & 13 deletions tests/Validator/ContainsIsEvenValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Idm\Bundle\Common\Tests\Validator;

use Throwable;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Idm\Bundle\Common\Validator\Constraints\IsEven;
use Idm\Bundle\Common\Validator\Constraints\IsEvenValidator;
use Idm\Bundle\Common\Validator\Constraints\IsOdd;
Expand All @@ -36,27 +37,21 @@ public function testEmptyIsValid()

public function testConstraintInvalid()
{
try
{
try {
$this->validator->validate(5, new IsOdd());
$this->assertFalse(true, 'Fail expect a exception for argument of Constrait not is correct');
}
catch (Throwable $th)
{
} catch (Throwable $th) {
// -- Expected argument of type "Idm\Bundle\Common\Validator\Constraints\IsEven", "Idm\Bundle\Common\Validator\Constraints\IsOdd" given
$this->assertNoViolation();
}
}

public function testNotValidNumber()
{
try
{
try {
$this->validator->validate('rr', new IsEven());
$this->assertFalse(true, 'Fail expect a exception for argument of type "int|float"');
}
catch (Throwable $th)
{
} catch (Throwable $th) {
// -- Expected argument of type "int|float", "string" given
$this->assertNoViolation();
}
Expand All @@ -68,8 +63,7 @@ public function testIsInvalid()

$this->buildViolation('idm.common.is_even')
->setParameter('{{ number }}', 5)
->assertRaised()
;
->assertRaised();
}

public function testIsValid()
Expand All @@ -79,7 +73,7 @@ public function testIsValid()
$this->assertNoViolation();
}

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new IsEvenValidator();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Validator/ContainsIsOddValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Idm\Bundle\Common\Tests\Validator;

use Throwable;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Idm\Bundle\Common\Validator\Constraints\IsEven;
use Idm\Bundle\Common\Validator\Constraints\IsOddValidator;
use Idm\Bundle\Common\Validator\Constraints\IsOdd;
Expand Down Expand Up @@ -79,7 +80,7 @@ public function testIsValid()
$this->assertNoViolation();
}

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new IsOddValidator();
}
Expand Down

0 comments on commit f37eb76

Please sign in to comment.