public function testGetDefaultExtensionIsBasedOnMimeType() { $file = new File(__DIR__ . '/Fixtures/test'); $guesser = $this->createMockGuesser($file->getPath(), 'image/gif'); MimeTypeGuesser::getInstance()->register($guesser); $this->assertEquals('.gif', $file->getDefaultExtension()); }
/** * Returns the mime type of the file. * * The mime type is guessed using the functions finfo(), mime_content_type() * and the system binary "file" (in this order), depending on which of those * is available on the current operating system. * * @returns string The guessed mime type, e.g. "application/pdf" */ public function getMimeType() { $guesser = MimeTypeGuesser::getInstance(); return $guesser->guess($this->getPath()); }