예제 #1
0
 /**
  * Creates a new Filesystem instance.
  *
  * @param  array  $config
  * @param  \Cartalyst\Filesystem\FilesystemManager  $manager
  * @return \Cartalyst\Filesystem\Filesystem
  */
 public function make(array $config, FilesystemManager $manager)
 {
     $adapter = $this->adapter->make($config);
     $filesystem = new Filesystem($adapter);
     $filesystem->setManager($manager);
     return $filesystem;
 }
예제 #2
0
 /**
  * @test
  */
 public function it_can_prepare_the_file_location_from_uploaded_file()
 {
     $adapter = m::mock('League\\Flysystem\\AdapterInterface');
     $manager = m::mock('Cartalyst\\Filesystem\\FilesystemManager');
     $file = m::mock('Symfony\\Component\\HttpFoundation\\File\\UploadedFile');
     $filesystem = new Filesystem($adapter);
     $filesystem->setManager($manager);
     $manager->shouldReceive('getPlaceholders')->once()->andReturn([':yyyy' => '2014', ':mm' => '01']);
     $manager->shouldReceive('getDispersion')->once()->andReturn(':extension/:yyyy/:mm/');
     $file->shouldReceive('getExtension')->once()->andReturn('jpg');
     $file->shouldReceive('getMimeType')->once()->andReturn('image/jpeg');
     $this->assertEquals('jpg/2014/01/file.png', $filesystem->prepareFileLocation($file, 'file.png'));
 }