예제 #1
0
 /**
  * Test that validate() validates the data against the schema rules.
  */
 public function testValidate()
 {
     $this->object->addField('username', 'Username')->addRule('username', 'alpha', 'Not alpha');
     $this->assertTrue($this->object->validate());
     $this->assertEquals(array(), $this->object->getErrors());
     // this will fail
     $this->object->addField('email', 'Email')->addRule('email', 'email', 'Invalid email');
     $this->assertFalse($this->object->validate());
     $this->assertEquals(array('email' => 'Invalid email'), $this->object->getErrors());
 }