Skip to content

Commit 9af29a3

Browse files
ISSUE-34: Added missing unit-test
1 parent abef8f9 commit 9af29a3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/BsnValidatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use DarkWebDesign\SymfonyAddon\Constraint\Tests\AbstractValidatorTestCase;
2626
use DarkWebDesign\SymfonyAddon\Constraint\Tests\Models\ToStringObject;
2727
use stdClass;
28+
use Symfony\Component\Validator\Constraints as Assert;
2829

2930
class BsnValidatorTest extends AbstractValidatorTestCase
3031
{
@@ -57,6 +58,16 @@ public function testValidate($bsn)
5758
$this->assertCount(0, $this->context->getViolations());
5859
}
5960

61+
/**
62+
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
63+
*/
64+
public function testValidateInvalidConstraint()
65+
{
66+
$this->validator->validate(array(), new Assert\NotNull());
67+
68+
$this->assertCount(0, $this->context->getViolations());
69+
}
70+
6071
public function testValidateNull()
6172
{
6273
$this->validator->validate(null, $this->constraint);

tests/JsonValidatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use DarkWebDesign\SymfonyAddon\Constraint\Tests\AbstractValidatorTestCase;
2626
use DarkWebDesign\SymfonyAddon\Constraint\Tests\Models\ToStringObject;
2727
use stdClass;
28+
use Symfony\Component\Validator\Constraints as Assert;
2829

2930
class JsonValidatorTest extends AbstractValidatorTestCase
3031
{
@@ -57,6 +58,16 @@ public function testValidate($json)
5758
$this->assertCount(0, $this->context->getViolations());
5859
}
5960

61+
/**
62+
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
63+
*/
64+
public function testValidateInvalidConstraint()
65+
{
66+
$this->validator->validate(array(), new Assert\NotNull());
67+
68+
$this->assertCount(0, $this->context->getViolations());
69+
}
70+
6071
public function testValidateNull()
6172
{
6273
$this->validator->validate(null, $this->constraint);

0 commit comments

Comments
 (0)