/** * */ public function testTypeWithoutFileInfo() { Runkit::requiredBy($this); Runkit::reimplementFunction('class_exists', '$className', 'return false;'); $FileInfo = new Transformist_FileInfo(vfsStream::url('root/accessible/empty')); $caught = false; try { $FileInfo->type(); } catch (Transformist_Exception $e) { $caught = true; } $this->assertTrue($caught); Runkit::resetFunction('class_exists'); }
/** * Lists documents based on the settings defined in setup( ). */ protected function _listDocuments() { if (empty($this->_pending)) { return; } foreach ($this->_pending['conversions'] as $in => $out) { if (!$this->_isMimeType($out)) { continue; } $mime = $this->_isMimeType($in); $pattern = $mime ? '*' : $in; $path = $this->_pending['input'] . DS . $pattern; $files = $this->_isGlobPattern($pattern) ? glob($path, GLOB_NOSORT) : array($path); if ($files) { foreach ($files as $file) { if ($mime) { $FileInfo = new Transformist_FileInfo($file); $type = false; try { $type = $FileInfo->type(); } catch (Transformist_Exception $exception) { //var_dump( $exception->getMessage( )); } if ($type !== $in) { continue; } } $Input = new Transformist_FileInfo($file, $mime ? $in : ''); $Output = new Transformist_FileInfo($this->_pending['output'] . DS . basename($file), $out); $Output->setExtension(Transformist_Registry::extension($out)); $this->addDocument(new Transformist_Document($Input, $Output)); } } } }