/** * Execute the console command * * @return void */ public function fire() { $dry = $this->input->getOption('dry-run'); foreach ($this->storage->deleteAllCrops($this->input->getOption('filter'), $dry) as $path) { $this->info(sprintf('%s %s', $path, $dry ? 'not deleted' : 'deleted')); } }
public function testFiltered() { $storage = new Storage(); $storage->setSrcDisk($this->src_dir); $storage->setCropsDisk($this->crops_dir); $this->assertEquals(['02/another-200x300.jpg'], $storage->listAllCrops('^02/')); }
private function mockHelpersForDeleting() { // The path is to a sub dir $url = new URL(['path' => 'uploads/(?:thumbs/)?(.*)$']); $src = Mockery::mock('League\\Flysystem\\Filesystem')->shouldReceive('listContents')->withAnyArgs()->andReturn([['path' => 'me.jpg', 'basename' => 'me.jpg'], ['path' => 'unrelated.jpg', 'basename' => 'unrelated.jpg']])->shouldReceive('delete')->withAnyArgs()->once()->getMock(); $crops = Mockery::mock('League\\Flysystem\\Filesystem')->shouldReceive('listContents')->withAnyArgs()->andReturn([['path' => 'me-200x100.jpg', 'basename' => 'me-200x100.jpg'], ['path' => 'me-200x200.jpg', 'basename' => 'me-200x200.jpg'], ['path' => 'me-200x300.jpg', 'basename' => 'me-200x300.jpg'], ['path' => 'unrelated.jpg', 'basename' => 'unrelated.jpg']])->shouldReceive('delete')->withAnyArgs()->times(3)->getMock(); $storage = new Storage(); $storage->setSrcDisk($src); $storage->setCropsDisk($crops); return new Helpers($url, $storage); }
public function testTooMany() { $storage = new Storage(null, ['max_crops' => 3]); $storage->setCropsDisk($this->dir); $this->assertTrue($storage->tooManyCrops('me.jpg')); }