示例#1
0
 public function testDoValidate_BasicValidatorObj()
 {
     $author = new Author();
     $author->setFirstName("Malcolm");
     // last name required, valid email format, age > 0
     $author->setLastName("X");
     $author->setEmail('malcolm@');
     // fail
     $res = $author->validate();
     $this->assertFalse($res, "Expected validation to fail.");
     $failures = $author->getValidationFailures();
     $this->assertEquals(1, count($failures), "Expected 1 column to fail validation.");
     $this->assertEquals(array(AuthorPeer::EMAIL), array_keys($failures), "Expected EMAIL to fail validation.");
     $validator = $failures[AuthorPeer::EMAIL]->getValidator();
     $this->assertTrue($validator instanceof MatchValidator, "Expected validator that failed to be MatchValidator");
 }