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'); }
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'); }
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); }
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()); } }