File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 2525use DarkWebDesign \SymfonyAddon \Constraint \Tests \AbstractValidatorTestCase ;
2626use DarkWebDesign \SymfonyAddon \Constraint \Tests \Models \ToStringObject ;
2727use stdClass ;
28+ use Symfony \Component \Validator \Constraints as Assert ;
2829
2930class 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 );
Original file line number Diff line number Diff line change 2525use DarkWebDesign \SymfonyAddon \Constraint \Tests \AbstractValidatorTestCase ;
2626use DarkWebDesign \SymfonyAddon \Constraint \Tests \Models \ToStringObject ;
2727use stdClass ;
28+ use Symfony \Component \Validator \Constraints as Assert ;
2829
2930class 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 );
You can’t perform that action at this time.
0 commit comments