protected function setUp() { $this->_files = dirname(dirname(dirname(__FILE__))) . '/data'; $this->_data = dirname(dirname(dirname(dirname(__FILE__)))) . '/data'; Type::config('magic', ['adapter' => 'Fileinfo']); Type::config('glob', ['adapter' => 'Freedesktop', 'file' => $this->_data . '/glob.db']); }
protected function setUp() { $this->_files = dirname(dirname(dirname(__FILE__))) . '/data'; $this->_data = dirname(dirname(dirname(dirname(__FILE__)))) . '/data'; Process::config(['image' => new GenericMock(null), 'audio' => new GenericMock(null), 'document' => new GenericMock(null), 'video' => new GenericMock(null)]); Type::config('magic', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/magic.db"]); Type::config('glob', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/glob.db"]); }
protected function setUp() { if (!extension_loaded('gd')) { $this->markTestSkipped('The `gd` extension is not available.'); } $this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data'; $this->_data = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/data'; Type::config('magic', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/magic.db"]); Type::config('glob', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/glob.db"]); }
protected function setUp() { $command = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? 'sox.exe' : 'sox'; exec("{$command} --version", $out, $return); if ($return != 0) { $this->markTestSkipped('The `sox` command is not available.'); } $this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data'; $this->_data = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/data'; Type::config('magic', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/magic.db"]); Type::config('glob', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/glob.db"]); }
protected function setUp() { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { exec("ffmpeg.exe -version>> nul 2>&1", $out, $return); } else { exec("ffmpeg -version &> /dev/null", $out, $return); } if ($return != 0) { $this->markTestSkipped('The `ffmpeg` command is not available.'); } $this->_files = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/data'; $this->_data = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . '/data'; Type::config('magic', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/magic.db"]); Type::config('glob', ['adapter' => 'Freedesktop', 'file' => "{$this->_data}/glob.db"]); }
/** * Load a track for processing * @param string $track The full path to the track */ public function loadTrack($track) { if (empty($track)) { throw new \Exception("A track must be supplied"); } if (!file_exists($track)) { throw new \Exception("Track [{$track}] not found"); } if (!is_readable($track)) { throw new \Exception("Track [{$track}] not readable"); } $this->track = $track; Type::config('magic', array('adapter' => 'Freedesktop', 'file' => dirname(__DIR__) . '/resources/magic.db')); Type::config('glob', array('adapter' => 'Freedesktop', 'file' => dirname(__DIR__) . '/resources/glob.db')); $this->extension = Type::guessExtension($this->track); if (empty($this->extension) || $this->extension == "bin") { $parts = pathinfo($this->track); $this->extension = $parts['extension']; } $this->mime = Type::guessType($this->track); }
/** * Load a track for processing * @param string $track The full path to the track */ public function loadTrack($track) { if (empty($track)) { throw new \Exception("A track must be supplied"); } if (!file_exists($track)) { throw new \Exception("Track [{$track}] not found"); } if (!is_readable($track)) { throw new \Exception("Track [{$track}] not readable"); } $this->track = $track; Type::config('magic', array('adapter' => 'Freedesktop', 'file' => dirname(__DIR__) . '/resources/magic.db')); Type::config('glob', array('adapter' => 'Freedesktop', 'file' => dirname(__DIR__) . '/resources/glob.db')); $this->extension = Type::guessExtension($this->track); //sometimes files report themselfs as bin or ico. whatever man ignore it if (empty($this->extension) || in_array($this->extension, array("bin", "ico"))) { $parts = pathinfo($this->track); $this->extension = $parts['extension']; } $this->mime = Type::guessType($this->track); }
* variant with the addtion of a `Fileinfo` magic adapter. Not all adapters require * a file to be passed along with the configuration. */ use mm\Mime\Type; if ($hasFileinfo) { Type::config('magic', ['adapter' => 'Fileinfo']); } else { Type::config('magic', ['adapter' => 'Freedesktop', 'file' => __DIR__ . '/data/magic.db']); } if ($cached = $cacheRead('mime_type_glob')) { Type::config('glob', ['adapter' => 'Memory']); foreach ($cached as $item) { Type::$glob->register($item); } } else { Type::config('glob', ['adapter' => 'Freedesktop', 'file' => __DIR__ . '/data/glob.db']); $cacheWrite('mime_type_glob', Type::$glob->to('array')); } /* * Configure the adpters to be used by the media process class. Adjust this * mapping of media names to adapters according to your environment. For example: * most PHP installations have GD enabled thus should choose the `Gd` adapter for * image transformations. However the `Imagick` adapter may be more desirable * in other cases and also supports transformations for documents. */ use mm\Media\Process; Process::config(['document' => $hasImagick ? 'Imagick' : null, 'image' => $hasImagick ? 'Imagick' : 'Gd']); /* * Configure the adpters to be used by the media info class. Adjust this * mapping of media names to adapters according to your environment. In contrast * to `Process` which operates only with one adapter per media type