public function testCallForwarder() { $manager = new MountManager(); $mock = Mockery::mock('League\\Flysystem\\FilesystemInterface'); $mock->shouldReceive('aMethodCall')->once()->andReturn('a result'); $manager->mountFilesystem('prot', $mock); $this->assertEquals($manager->aMethodCall('prot://file.ext'), 'a result'); }
/** * Get the filesystem manager. * * @return MountManager * @throws \Exception */ public static function getFilesystem() { $config = new Config(); $manager = new MountManager(); foreach ($config->filesystems() as $name => $fsConfig) { $adapterName = '\\League\\Flysystem\\Adapter\\' . self::camelcase($fsConfig['type']); $adapter = new $adapterName($fsConfig['root']); $fs = new Filesystem($adapter); $manager->mountFilesystem($name, $fs); } return $manager; }
/** * Mainly passes through to parent class, but before it does this method * checks that the passed in directory exists. * * @return void **/ public function mount($prefix, $location) { if (is_dir($location)) { return parent::mountFilesystem($prefix, new Filesystem(new FilesystemAdapter($location))); } }
/** * Mounts a local filesystem if the directory exists. * * @param string $prefix * @param string $location * * @return $this */ public function mount($prefix, $location) { return parent::mountFilesystem($prefix, $this->createFilesystem($location)); }
public function testListWith() { $manager = new MountManager(); $response = ['path' => 'file.ext', 'timestamp' => time()]; $mock = Mockery::mock('League\\Flysystem\\FilesystemInterface'); $mock->shouldReceive('listWith')->with(['timestamp'], 'file.ext', false)->once()->andReturn($response); $manager->mountFilesystem('prot', $mock); $this->assertEquals($response, $manager->listWith(['timestamp'], 'prot://file.ext', false)); }