Пример #1
0
 /**
  * @todo Implement testGetMimeType().
  */
 public function testGetMimeTypeUnknown()
 {
     $stub = $this->getMock("Versionable\\Ferret\\Detector\\DetectorInterface");
     $stub->expects($this->any())->method('detect')->will($this->returnValue(false));
     $this->object->setDetector($stub);
     $this->assertFalse($this->object->getMimeType('somefile.unknown'));
 }
Пример #2
0
 public function loadFile($filename)
 {
     if (false === is_readable($filename)) {
         throw new \InvalidArgumentException(sprintf('%s not readable', $filename));
     }
     $detector = new Composite();
     $detector->addDetector(new Fileinfo());
     $detector->addDetector(new Pathinfo());
     $ferret = new Ferret();
     $ferret->setDetector($detector);
     $mimetype = $ferret->getMimeType($filename);
     $this->setType($mimeType);
     $this->setContent(file_get_contents($filename));
 }