/**
  * Gets the list of extensions (if limited) for this field. Empty list
  * means there is no restriction on allowed types.
  *
  * @return array
  */
 protected function getAllowedExtensions()
 {
     $categories = $this->getAllowedCategories();
     return File::get_category_extensions($categories);
 }
 /**
  * Limit allowed file extensions by specifying categories of file types.
  * These may be 'image', 'image/supported', 'audio', 'video', 'archive', 'flash', or 'document'
  * See {@link File::$allowed_extensions} for details of allowed extensions
  * for each of these categories
  *
  * @param string $category Category name
  * @param string,... $categories Additional category names
  * @return $this
  */
 public function setAllowedFileCategories($category)
 {
     $extensions = File::get_category_extensions(func_get_args());
     return $this->setAllowedExtensions($extensions);
 }
 public function testGetCategoryExtensions()
 {
     // Test specific categories
     $images = array('alpha', 'als', 'bmp', 'cel', 'gif', 'ico', 'icon', 'jpeg', 'jpg', 'pcx', 'png', 'ps', 'tif', 'tiff');
     $this->assertEquals($images, File::get_category_extensions('image'));
     $this->assertEquals(array('gif', 'jpeg', 'jpg', 'png'), File::get_category_extensions('image/supported'));
     $this->assertEquals($images, File::get_category_extensions(array('image', 'image/supported')));
     $this->assertEquals(array('fla', 'gif', 'jpeg', 'jpg', 'png', 'swf'), File::get_category_extensions(array('flash', 'image/supported')));
     // Test other categories have at least one item
     $this->assertNotEmpty(File::get_category_extensions('archive'));
     $this->assertNotEmpty(File::get_category_extensions('audio'));
     $this->assertNotEmpty(File::get_category_extensions('document'));
     $this->assertNotEmpty(File::get_category_extensions('flash'));
     $this->assertNotEmpty(File::get_category_extensions('video'));
 }