예제 #1
0
 public function testSetAndGetMagicFile()
 {
     $validator = new File\MimeType('image/gif');
     $magic = getenv('magic');
     if (!empty($magic)) {
         $mimetype = $validator->getMagicFile();
         $this->assertEquals($magic, $mimetype);
     }
     $this->setExpectedException('Zend\\Validator\\Exception\\InvalidArgumentException', 'could not be');
     $validator->setMagicFile('/unknown/magic/file');
 }
예제 #2
0
 public function testSetAndGetMagicFile()
 {
     if (!extension_loaded('fileinfo')) {
         $this->markTestSkipped('This PHP Version has no finfo installed');
     }
     $validator = new File\MimeType('image/gif');
     $magic = getenv('magic');
     if (!empty($magic)) {
         $mimetype = $validator->getMagicFile();
         $this->assertEquals($magic, $mimetype);
     }
     $this->setExpectedException('Zend\\Validator\\Exception\\InvalidArgumentException', 'could not be');
     $validator->setMagicFile('/unknown/magic/file');
 }
예제 #3
0
 public function getInputSpecification()
 {
     $validators = array();
     $mimetypes = $this->getAllowedTypes();
     $fileCount = $this->getMaxFileCount();
     if ($mimetypes) {
         $mimeTypeValidator = new MimeType();
         $mimeTypeValidator->setMagicFile(false)->disableMagicFile(true)->setMimeType($this->getAllowedTypes());
         $validators[] = $mimeTypeValidator;
     }
     $validators[] = new Size($this->getMaxSize());
     if (0 < $fileCount) {
         $validators[] = new Callback(array($this, 'fileCountValidationCallback'));
     }
     return array('name' => $this->getName(), 'required' => false, 'validators' => $validators);
 }
예제 #4
0
 public function testSetAndGetMagicFile()
 {
     $validator = new File\MimeType('image/gif');
     if (!empty($_ENV['MAGIC'])) {
         $mimetype = $validator->getMagicFile();
         $this->assertEquals($_ENV['MAGIC'], $mimetype);
     }
     try {
         $validator->setMagicFile('/unknown/magic/file');
     } catch (Validator\Exception $e) {
         $this->assertContains('can not be', $e->getMessage());
     }
 }