public function testGuessMimeType() { $file = new File($this->root . '/test.gif'); $this->assertEquals('image/gif', $file->guessMimeType()); $file = new File($this->root . '/test'); $this->assertEquals('image/gif', $file->guessMimeType()); $file = new File($this->root . '/other-file.example'); $this->assertEquals('inode/x-empty', $file->guessMimeType()); $file = new File($this->root . '/.unknownextension'); $this->assertEquals('application/octet-stream', $file->guessMimeType()); }
/** * @param string $path * @param string $name * @param null $size * @param null $mimeType * @param null $error */ public function __construct($path, $name, $size = null, $mimeType = null, $error = null) { $this->name = $this->getName($name); $this->size = $size; $this->mimeType = $mimeType ?: 'application/octet-stream'; $this->error = $error ?: UPLOAD_ERR_OK; parent::__construct($path, UPLOAD_ERR_OK == $this->error); }