當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MimeMagic::analyze方法代碼示例

本文整理匯總了PHP中MimeMagic::analyze方法的典型用法代碼示例。如果您正苦於以下問題:PHP MimeMagic::analyze方法的具體用法?PHP MimeMagic::analyze怎麽用?PHP MimeMagic::analyze使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MimeMagic的用法示例。


在下文中一共展示了MimeMagic::analyze方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testShippedAnalyze

 function testShippedAnalyze()
 {
     $file = dirname(dirname(dirname(dirname(__FILE__)))) . DS . 'vendors' . DS . 'mime_magic.db';
     $skip = $this->skipIf(!file_exists($file), '%s. No shipped magic db.');
     if ($skip) {
         /* Skipping does not silence the error */
         $this->expectError();
     }
     $Mime = new MimeMagic($file);
     $this->assertEqual($Mime->analyze($this->TestData->getFile('ms.snippet.avi')), 'video/x-msvideo');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('image-gif.gif')), 'image/gif');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('application-pdf.pdf')), 'application/pdf');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('postscript.snippet.ps')), 'application/postscript');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('tar.snippet.tar')), 'application/x-tar');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('wave.snippet.wav')), 'audio/x-wav');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('3gp.snippet.3gp')), 'video/3gpp');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('bzip2.snippet.bz2')), 'application/x-bzip');
     //application/x-bzip2
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video.snippet.mp4')), 'video/mp4');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('gzip.snippet.gz')), 'application/x-gzip');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('text-html.snippet.html')), 'text/html');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('image-jpeg.snippet.jpg')), 'image/jpeg');
     //audio/MP4A-LATM
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video-mpeg.snippet.mpeg')), 'video/mpeg');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video-ogg.snippet.ogv')), 'video/x-theora+ogg');
     //application/ogg
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-ogg.snippet.ogg')), 'audio/x-vorbis+ogg');
     //application/ogg
     $this->assertEqual($Mime->analyze(__FILE__), 'application/x-php');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('image-png.png')), 'image/png');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('text-rtf.snippet.rtf')), 'application/rtf');
     //text/rtf
     $this->assertEqual($Mime->analyze($this->TestData->getFile('ms-word.snippet.doc')), 'application/msword');
     //audio/MP4A-LATM
     $this->assertEqual($Mime->analyze($this->TestData->getFile('xml.snippet.xml')), 'application/xml');
     //text/xml
     /* Fail! */
     /*
     $this->assertEqual($Mime->analyze($this->TestData->getFile('opendocument-writer.snippet.odt')), 'application/vnd.oasis.opendocument.text');//application/zip
     $this->assertEqual($Mime->analyze($this->TestData->getFile('ms-word.snippet.docx')), 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');//application/zip
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-mpeg.snippet.mp3')), 'audio/mpeg');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('text-plain.snippet.txt')), 'text/plain');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('css.snippet.css')), 'text/css');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('javascript.snippet.js')), 'application/javascript');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('text-xhtml.snippet.xhtml')), 'application/xhtml+xml');//text/xml
     $this->assertEqual($Mime->analyze($this->TestData->getFile('po.snippet.po')), 'text/x-gettext-translation');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('text-pot.snippet.pot')), 'text/x-gettext-translation-template');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('mo.snippet.mo')), 'application/x-gettext-translation');
     */
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video-flash.snippet.flv')), 'video/x-flv');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio.snippet.snd')), 'audio/basic');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-apple.snippet.aiff')), 'audio/x-aiff');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('flash.snippet.swf')), 'application/x-shockwave-flash');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-mpeg.snippet.m4a')), 'audio/mp4');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-musepack.snippet.mpc')), 'audio/x-musepack');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video-quicktime.snippet.mov')), 'video/quicktime');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('video-ms.snippet.wmv')), 'video/x-ms-asf');
     /* Fail! */
     /*
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio.snippet.aac')), 'audio/x-aac');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('audio-ms.snippet.wma')), 'audio/x-ms-asf');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('flac.snippet.flac')), 'audio/x-flac');//Fail only with freedesktop db!
     */
     /* Audio formats to find/add/test:
     		riff,wavpack, aac, ac3, ape, shorten, midi, voc, s3m, xm, it, mod, matroska, pac, bonk, dts, cda */
     /* Fail! No data :( */
     /*
     $this->assertEqual($Mime->analyze($this->TestData->getFile('java.snippet.class')), 'application/x-java');
     $this->assertEqual($Mime->analyze($this->TestData->getFile('real-video.snippet.rm')), 'application/vnd.rn-realmedia');
     */
 }
開發者ID:youkidearitai,項目名稱:CakePHP-Media-Plugin,代碼行數:71,代碼來源:mime_magic.test.php


注:本文中的MimeMagic::analyze方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。