Exemple #1
0
 /**
  * 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'));
     }
 }
Exemple #2
0
 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/'));
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 public function testTooMany()
 {
     $storage = new Storage(null, ['max_crops' => 3]);
     $storage->setCropsDisk($this->dir);
     $this->assertTrue($storage->tooManyCrops('me.jpg'));
 }