Exemple #1
0
 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(null, true), array('zip', true), array('test/notype', false), array('application/zip, application/x-tar', true), array(array('application/zip', 'application/x-tar'), true), array(array('zip', 'tar'), true), array(array('tar', 'arj'), false));
     $files = array('name' => 'test.zip', 'type' => 'application/zip', 'size' => 200, 'tmp_name' => dirname(__FILE__) . '/_files/test.zip', 'error' => 0);
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_File_IsCompressed($element[0]);
         $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/test.zip', $files));
     }
 }
Exemple #2
0
 /**
  * @ZF-8111
  */
 public function testErrorMessages()
 {
     $files = array('name' => 'picture.jpg', 'type' => 'image/jpeg', 'size' => 200, 'tmp_name' => dirname(__FILE__) . '/_files/picture.jpg', 'error' => 0);
     $validator = new Zend_Validate_File_IsCompressed('test/notype');
     $validator->enableHeaderCheck();
     $this->assertFalse($validator->isValid(dirname(__FILE__) . '/_files/picture.jpg', $files));
     $error = $validator->getMessages();
     $this->assertTrue(array_key_exists('fileIsCompressedFalseType', $error));
 }