Ejemplo n.º 1
0
 /**
  * Test that getList() methods return the correct amount of mime types.
  */
 public function testGetList()
 {
     $this->assertEquals(661, count(MimeType::getApplicationList()));
     $this->assertEquals(42, count(MimeType::getAudioList()));
     $this->assertEquals(54, count(MimeType::getImageList()));
     $this->assertEquals(77, count(MimeType::getTextList()));
     $this->assertEquals(51, count(MimeType::getVideoList()));
 }
Ejemplo n.º 2
0
 /**
  * Validate the top-level type of file, e.g., image.
  *
  * @uses Transit\MimeType
  *
  * @param string|array $mimeTypes
  * @return bool
  */
 public function type($mimeTypes)
 {
     $types = array();
     foreach ((array) $mimeTypes as $mimeType) {
         switch ($mimeType) {
             case 'application':
                 $types += MimeType::getApplicationList();
                 break;
             case 'audio':
                 $types += MimeType::getAudioList();
                 break;
             case 'image':
                 $types += MimeType::getImageList();
                 break;
             case 'text':
                 $types += MimeType::getTextList();
                 break;
             case 'video':
                 $types += MimeType::getVideoList();
                 break;
             default:
                 $types += MimeType::getSubTypeList($mimeType);
                 break;
         }
     }
     return in_array($this->getFile()->type(), $types);
 }