示例#1
0
 public function testValidateEmptyData()
 {
     $validator = new ArrayValidator(new Validate(), array(new Property('id', Validate::TYPE_INTEGER), new Property('title', Validate::TYPE_STRING, array(new Filter\Length(2, 8))), new Property('date', Validate::TYPE_STRING, array(new Filter\DateTime()))));
     $result = $validator->validate(array());
     $this->assertArrayHasKey('id', $result);
     $this->assertEquals(null, $result['id']);
     $this->assertArrayHasKey('title', $result);
     $this->assertEquals(null, $result['title']);
     $this->assertArrayHasKey('date', $result);
     $this->assertEquals(null, $result['date']);
 }
示例#2
0
 public function testGetRecord()
 {
     $validator = new ArrayValidator(new Validate(), array(new Property('id', Validate::TYPE_INTEGER), new Property('title', Validate::TYPE_STRING, array(new Filter\Length(1, 2)))));
     $this->assertInstanceOf('PSX\\Data\\RecordInterface', $validator->getRecord());
     $this->assertEquals(array('id' => null, 'title' => null), $validator->getRecord()->getRecordInfo()->getFields());
 }