'pages']]); Setting::set('sizes', []); Setting::set('breakpoints', []); $this->media->put('pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Artisan::call('resize:make'); $this->assertFileCount(1, 'pages'); } public function testItDeletesOtherFilesBeforeResizingAll() { Setting::set('folders', [['folder' => 'pages']]); Setting::set('sizes', []); Setting::set('breakpoints', []); Storage::put('uploads/public/c/otherdir/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Artisan::call('resize:make'); $this->assertFileCount(0, 'otherdir'); } public function testOnlyResizeASingleFolder() { Setting::set('folders', [ ['folder' => 'pages'], ['folder' => 'otherdir'], ]); Setting::set('sizes', []); Setting::set('breakpoints', []); $this->media->put('pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Storage::put('uploads/public/c/pages/test-100x100.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('otherdir/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Storage::put('uploads/public/c/otherdir/test-100x100.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Storage::put('uploads/public/c/otherdir/test-200x200.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Artisan::call('resize:make', ['-f' => 'pages']); $this->assertFileCount(2, 'otherdir'); $this->assertFileCount(1, 'pages'); } public function testCleanSingleFolderBeforeResizing() { Setting::set('folders', [ ['folder' => '/pages'], ['folder' => 'otherdir'], ]); Setting::set('sizes', []); Setting::set('breakpoints', []); Storage::put('uploads/public/c/pages/test-100x100.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); Artisan::call('resize:make', ['-f' => '/pages']); $this->assertFileCount(0, 'pages'); } public function testOnlyResizeMissingBreakpointsIfUpdateGiven() { Setting::set('folders', [ ['folder' => '/pages'], ['folder' => 'otherdir'], ]); Setting::set('sizes', []); Setting::set('breakpoints', [100, 200]); $this->media->put('pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); Storage::put('uploads/public/c/pages/test-200x200.jpg', UploadedFile::fake()->image('test.jpg', 200, 200)->get()); $lastModified = Storage::lastModified('uploads/public/c/pages/test-200x200.jpg'); sleep(1); Artisan::call('resize:make', ['-u' => true]); $this->assertFileCount(3, 'pages'); $this->assertEquals($lastModified, Storage::lastModified('uploads/public/c/pages/test-200x200.jpg')); } public function testOnlyResizeMissingVersionsIfUpdateGiven() { Setting::set('folders', [ ['folder' => '/pages'], ['folder' => 'otherdir'], ]); Setting::set('sizes', [['name' => 'testas', 'aspect_ratio' => '1x2']]); Setting::set('breakpoints', [100, 200]); $this->media->put('pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); Storage::put('uploads/public/c/pages/test-100x200.jpg', UploadedFile::fake()->image('test.jpg', 100, 200)->get()); $lastModified = Storage::lastModified('uploads/public/c/pages/test-100x200.jpg'); sleep(1); Artisan::call('resize:make', ['-u' => true]); $this->assertEquals($lastModified, Storage::lastModified('uploads/public/c/pages/test-100x200.jpg')); } }