Ejemplo n.º 1
0
 public function testSetup()
 {
     $app = $this->getApp();
     $adapter = new Local(PHPUNIT_ROOT . '/resources');
     $fs = new Filesystem($adapter);
     $manager = new Manager([]);
     $manager->mountFilesystem('files', $fs);
     $manager->addPlugin(new Plugin\ThumbnailUrl($app));
     $result = $fs->thumb('generic-logo.png', 200, 200, 'crop');
     $this->assertEquals('/thumbs/200x200c/generic-logo.png', $result);
 }
Ejemplo n.º 2
0
 public function testHandle()
 {
     $adapter = new Local(PHPUNIT_ROOT . '/resources');
     $fs = new Filesystem($adapter);
     $manager = new Manager([]);
     $manager->mountFilesystem('files', $fs);
     $urlGenerator = $this->createMock(UrlGeneratorInterface::class);
     $urlGenerator->expects($this->once())->method('generate')->with('thumb', ['width' => 200, 'height' => 200, 'action' => 'c', 'file' => 'generic-logo.png'])->willReturn('/thumbs/200x200c/generic-logo.png');
     $manager->addPlugin(new Plugin\ThumbnailUrl($urlGenerator));
     $result = $fs->thumb('generic-logo.png', 200, 200, 'crop');
     $this->assertEquals('/thumbs/200x200c/generic-logo.png', $result);
 }
Ejemplo n.º 3
0
 public function testSetup()
 {
     $app = $this->getApp();
     $adapter = new Local(PHPUNIT_ROOT . '/resources');
     $fs1 = new Filesystem($adapter);
     $fs2 = new Filesystem($adapter);
     $fs3 = new Filesystem($adapter);
     $manager = new Manager([]);
     $manager->mountFilesystem('files', $fs1);
     $manager->mountFilesystem('cache', $fs2);
     $manager->mountFilesystem('something', $fs3);
     $manager->addPlugin(new Plugin\Authorized($app));
     $this->assertTrue($fs1->authorized(''));
     $this->assertFalse($fs2->authorized(''));
     $this->assertFalse($fs3->authorized(''));
 }
Ejemplo n.º 4
0
Archivo: Edit.php Proyecto: suood/bolt
 /**
  * Test write access for uploadable fields.
  * Autocreates the desired directory if it does not exist.
  *
  * @param array $fields
  *
  * @return array
  */
 private function setCanUpload($fields)
 {
     $filesystem = $this->filesystem->getFilesystem('files');
     foreach ($fields as &$values) {
         if (isset($values['upload'])) {
             $values['canUpload'] = ($filesystem->has($values['upload']) || $filesystem->createDir($values['upload'])) && $filesystem->getVisibility($values['upload']);
         } else {
             $values['canUpload'] = true;
         }
     }
     return $fields;
 }
Ejemplo n.º 5
0
 /**
  * Check a given upload path to see if it is 'public' or 'private' access, create if required.
  *
  * @param $path
  *
  * @return boolean
  */
 private function checkUploadDirectory($path)
 {
     if ($this->filesystem->has($path)) {
         return $this->filesystem->getVisibility($path) === 'public';
     }
     try {
         $this->filesystem->createDir($path);
         return $this->filesystem->getVisibility($path) === 'public';
     } catch (IOException $e) {
         return false;
     }
 }
Ejemplo n.º 6
0
 /**
  * Check a given upload path to see if it is 'public' or 'private' access, create if required.
  *
  * @param $path
  *
  * @return boolean
  */
 private function checkUploadDirectory($path)
 {
     if (strpos('://', $path) === false) {
         $path = sprintf('files://%s', $path);
     }
     if ($this->filesystem->has($path)) {
         return $this->filesystem->getVisibility($path) === 'public';
     }
     try {
         $this->filesystem->createDir($path);
         return $this->filesystem->getVisibility($path) === 'public';
     } catch (IOException $e) {
         return false;
     }
 }
Ejemplo n.º 7
0
 protected function createResponder($saveFiles = false)
 {
     $responder = new Responder($this->creator, $this->finder, $this->errorImage, $saveFiles ? $this->fs->getFilesystem('web') : null, $this->cache);
     return $responder;
 }
Ejemplo n.º 8
0
 public function testImageNotFoundUsesDefault()
 {
     $image = $this->finder->find('herp/derp.png');
     $this->assertSame($this->fs->getFilesystem('images'), $image->getFilesystem());
     $this->assertSame('samples/sample1.jpg', $image->getPath());
 }