Fixed: Delete images

This commit is contained in:
philipp lang 2022-02-16 02:49:19 +01:00
parent 72ef92b78c
commit 30bd3dc25f
13 changed files with 249 additions and 58 deletions

1
.ackrc Normal file
View File

@ -0,0 +1 @@
--ignore-dir=/vendor

View File

@ -8,7 +8,10 @@ use Aweos\Resizer\Classes\ImageResizer;
use Aweos\Resizer\Classes\ResizeJob; use Aweos\Resizer\Classes\ResizeJob;
use Aweos\Resizer\Console\ResizeMake; use Aweos\Resizer\Console\ResizeMake;
use Aweos\Resizer\Console\ResizePurge; use Aweos\Resizer\Console\ResizePurge;
use Aweos\Resizer\Jobs\DeleteJob;
use Aweos\Resizer\Jobs\MoveJob;
use Aweos\Resizer\Lib\MediaPath; use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\StorageMediaPath;
use Aweos\Resizer\Models\Setting; use Aweos\Resizer\Models\Setting;
use Event; use Event;
use MediaLibrary; use MediaLibrary;
@ -65,22 +68,23 @@ class Plugin extends PluginBase
app()->bind('resize', fn () => app(CacheManager::class)); app()->bind('resize', fn () => app(CacheManager::class));
Event::listen('media.file.upload', function($widget, $filePath, $uploadedFile) { Event::listen('media.file.upload', function($widget, $filePath, $uploadedFile) {
if ((new MediaPath($filePath))->shouldProcess()) { if ((new StorageMediaPath($filePath))->shouldProcess()) {
Queue::push(ResizeJob::class, [$filePath], Setting::get('queue')); Queue::push(ResizeJob::class, [$filePath], Setting::get('queue'));
} }
}); });
Event::listen('media.file.delete', function($widget, $filePath) { Event::listen('media.file.delete', function($widget, $filePath) {
app(FileObserver::class)->delete(new MediaPath($filePath)); Queue::push(DeleteJob::class, [$filePath], Setting::get('queue'));
app(CacheManager::class)->delete(new MediaPath($filePath));
}); });
Event::listen('media.file.move', function($widget, $old, $new) { Event::listen('media.file.move', function($widget, $old, $new) {
app(FileObserver::class)->rename(new MediaPath($old), new MediaPath($new)); if ((new StorageMediaPath($new))->shouldProcess() || (new StorageMediaPath($old))->shouldProcess()) {
app(CacheManager::class)->delete(new MediaPath($old)); Queue::push(MoveJob::class, [$old, $new], Setting::get('queue'));
}
}); });
Event::listen('media.file.rename', function($widget, $old, $new) { Event::listen('media.file.rename', function($widget, $old, $new) {
app(FileObserver::class)->rename(new MediaPath($old), new MediaPath($new)); if ((new StorageMediaPath($old))->shouldProcess()) {
app(CacheManager::class)->delete(new MediaPath($old)); Queue::push(MoveJob::class, [$old, $new], Setting::get('queue'));
}
}); });
} }
@ -103,7 +107,7 @@ class Plugin extends PluginBase
return [ return [
'filters' => [ 'filters' => [
'resize' => fn ($media, $size = 'original', $sizes = null, $options = []) => app(CacheManager::class)->get( 'resize' => fn ($media, $size = 'original', $sizes = null, $options = []) => app(CacheManager::class)->get(
new MediaPath($media), new StorageMediaPath($media),
$size, $size,
$sizes, $sizes,
$options, $options,

View File

@ -3,6 +3,7 @@
namespace Aweos\Resizer\Classes; namespace Aweos\Resizer\Classes;
use Aweos\Resizer\Lib\MediaPath; use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\StorageMediaPath;
use Cache; use Cache;
class CacheManager class CacheManager
@ -51,7 +52,7 @@ class CacheManager
public function biggestVersion(string $path, string $size): string public function biggestVersion(string $path, string $size): string
{ {
$path = new MediaPath($path); $path = new StorageMediaPath($path);
return $this->tagGenerator->singleFile($path, $size); return $this->tagGenerator->singleFile($path, $size);
} }

View File

@ -4,6 +4,7 @@ namespace Aweos\Resizer\Classes;
use Aweos\Resizer\Classes\CacheManager; use Aweos\Resizer\Classes\CacheManager;
use Aweos\Resizer\Lib\MediaPath; use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\TempMediaPath;
use Log; use Log;
use Throwable; use Throwable;
@ -13,9 +14,10 @@ class ResizeJob
public function fire($job, $params) public function fire($job, $params)
{ {
list($file) = $params; list($file) = $params;
$media = new MediaPath($file); $media = new TempMediaPath($file);
app(ImageResizer::class)->generate($media, $params['update'] ?? false); app(ImageResizer::class)->generate($media, $params['update'] ?? false);
app(CacheManager::class)->delete($media); app(CacheManager::class)->delete($media);
unset ($media);
$job->delete(); $job->delete();
} }

View File

@ -20,7 +20,9 @@
"Aweos\\Resizer\\Compilers\\": "./compilers", "Aweos\\Resizer\\Compilers\\": "./compilers",
"Aweos\\Resizer\\Exceptions\\": "./exceptions", "Aweos\\Resizer\\Exceptions\\": "./exceptions",
"Aweos\\Resizer\\Compressors\\": "./compressors", "Aweos\\Resizer\\Compressors\\": "./compressors",
"Aweos\\Resizer\\Lib\\": "./lib" "Aweos\\Resizer\\Lib\\": "./lib",
"Aweos\\Resizer\\Jobs\\": "./jobs",
"Aweos\\Resizer\\Classes\\": "./classes"
} }
} }
} }

36
jobs/DeleteJob.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace Aweos\Resizer\Jobs;
use Aweos\Resizer\Classes\CacheManager;
use Aweos\Resizer\Classes\FileObserver;
use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\StorageMediaPath;
use Log;
use Throwable;
class DeleteJob
{
public function fire($job, $params)
{
list($file) = $params;
$media = new StorageMediaPath($file);
app(FileObserver::class)->delete($media);
app(CacheManager::class)->delete($media);
unset ($media);
$job->delete();
}
public function failed($data, Throwable $e)
{
Log::error("Deleting of image failed", [
'message' => $e->getMessage(),
'exception' => $e,
'data' => $data,
]);
throw $e;
}
}

38
jobs/MoveJob.php Normal file
View File

@ -0,0 +1,38 @@
<?php
namespace Aweos\Resizer\Jobs;
use Aweos\Resizer\Classes\CacheManager;
use Aweos\Resizer\Classes\FileObserver;
use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\StorageMediaPath;
use Log;
use Throwable;
class MoveJob
{
public function fire($job, $params)
{
list($old, $new) = $params;
$old = new StorageMediaPath($old);
$new = new StorageMediaPath($new);
app(FileObserver::class)->rename($old, $new);
app(CacheManager::class)->delete($old);
unset ($old);
unset ($new);
$job->delete();
}
public function failed($data, Throwable $e)
{
Log::error("Deleting of image failed", [
'message' => $e->getMessage(),
'exception' => $e,
'data' => $data,
]);
throw $e;
}
}

35
jobs/ResizeJob.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace Aweos\Resizer\Jobs;
use Aweos\Resizer\Classes\CacheManager;
use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\TempMediaPath;
use Log;
use Throwable;
class ResizeJob
{
public function fire($job, $params)
{
list($file) = $params;
$media = new TempMediaPath($file);
app(ImageResizer::class)->generate($media, $params['update'] ?? false);
app(CacheManager::class)->delete($media);
unset ($media);
$job->delete();
}
public function failed($data, Throwable $e)
{
Log::error("Resizing of image failed", [
'message' => $e->getMessage(),
'exception' => $e,
'data' => $data,
]);
throw $e;
}
}

View File

@ -9,26 +9,19 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use MediaLibrary; use MediaLibrary;
class MediaPath abstract class MediaPath
{ {
private string $path; protected string $path;
abstract public function get(): string;
abstract public function root(): string;
abstract public function publicUrl(): string;
public function __construct(string $path) public function __construct(string $path)
{ {
$this->path = $path; $this->path = $path;
} }
public function root(): string
{
return Storage::path($this->storagePath());
}
public function storagePath(): string
{
return "media/{$this->normal()}";
}
public function normal(): string public function normal(): string
{ {
return preg_replace('|^/*|', '', $this->path); return preg_replace('|^/*|', '', $this->path);
@ -41,7 +34,7 @@ class MediaPath
public function filename(): string public function filename(): string
{ {
return pathinfo($this->path, PATHINFO_FILENAME); return pathinfo($this->root(), PATHINFO_FILENAME);
} }
public function exists(): bool public function exists(): bool
@ -60,7 +53,7 @@ class MediaPath
public function extension(): string public function extension(): string
{ {
return pathinfo($this->path, PATHINFO_EXTENSION); return pathinfo($this->root(), PATHINFO_EXTENSION);
} }
public function versionsPath(): string public function versionsPath(): string
@ -70,17 +63,7 @@ class MediaPath
public function versionsDirPath(): string public function versionsDirPath(): string
{ {
return pathinfo("uploads/public/c/{$this->normal()}", PATHINFO_DIRNAME); return pathinfo($this->versionsPath(), PATHINFO_DIRNAME);
}
public function publicUrl(): string
{
return MediaLibrary::instance()->findFiles($this->path)[0]->publicUrl;
}
public function get(): string
{
return MediaLibrary::instance()->get($this->path);
} }
public function shouldProcess(): bool public function shouldProcess(): bool
@ -122,4 +105,9 @@ class MediaPath
return $return; return $return;
} }
protected function storagePath(): string
{
return "media/{$this->normal()}";
}
} }

36
lib/StorageMediaPath.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace Aweos\Resizer\Lib;
use Aweos\Resizer\Compressors\Compressor;
use Aweos\Resizer\Compressors\Factory as CompressorFactory;
use Aweos\Resizer\Models\Setting;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use MediaLibrary;
class StorageMediaPath extends MediaPath
{
public function __construct(string $path)
{
parent::__construct($path);
$this->path = $path;
}
public function root(): string
{
return Storage::path($this->storagePath());
}
public function publicUrl(): string
{
return MediaLibrary::instance()->findFiles($this->path)[0]->publicUrl;
}
public function get(): string
{
return MediaLibrary::instance()->get($this->path);
}
}

59
lib/TempMediaPath.php Normal file
View File

@ -0,0 +1,59 @@
<?php
namespace Aweos\Resizer\Lib;
use Aweos\Resizer\Compressors\Compressor;
use Aweos\Resizer\Compressors\Factory as CompressorFactory;
use Aweos\Resizer\Models\Setting;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use MediaLibrary;
class TempMediaPath extends MediaPath
{
private string $tempPath;
public function __construct(string $path)
{
parent::__construct($path);
$this->createTemp();
}
public function __destruct()
{
$this->destroyTemp();
}
public function root(): string
{
return $this->tempPath;
}
public function publicUrl(): string
{
return '';
}
public function get(): string
{
return file_get_contents($this->tempPath);
}
private function createTemp(): void
{
$this->tempPath = '/tmp/'.pathinfo($this->path, PATHINFO_FILENAME);
if (Storage::exists($this->storagePath())) {
$stream = Storage::readStream($this->storagePath());
$contents = stream_get_contents($stream);
file_put_contents($this->tempPath, $contents);
}
}
private function destroyTemp(): void
{
@unlink($this->tempPath);
}
}

View File

@ -6,6 +6,7 @@ use Aweos\Resizer\Classes\CacheManager;
use Aweos\Resizer\Classes\TagGenerator; use Aweos\Resizer\Classes\TagGenerator;
use Aweos\Resizer\Exceptions\ResizerException; use Aweos\Resizer\Exceptions\ResizerException;
use Aweos\Resizer\Lib\MediaPath; use Aweos\Resizer\Lib\MediaPath;
use Aweos\Resizer\Lib\StorageMediaPath;
use Aweos\Resizer\Models\Setting; use Aweos\Resizer\Models\Setting;
use Aweos\Resizer\Tests\TestCase; use Aweos\Resizer\Tests\TestCase;
use Cache; use Cache;
@ -21,11 +22,11 @@ class ImageTagTest extends TestCase
{ {
parent::setUp(); parent::setUp();
Storage::fake('local'); Storage::fake('local');
Setting::set('folders', [['folder' => '/pages']]);
} }
public function testItGeneratesAnImageTagWithOriginalSize() public function testItGeneratesAnImageTagWithOriginalSize()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100,200]); Setting::set('breakpoints', [100,200]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
@ -35,25 +36,23 @@ class ImageTagTest extends TestCase
$this->assertEquals( $this->assertEquals(
'width="500" height="500" sizes="(max-width: 100px) 100px, (max-width: 200px) 200px, (max-width: 500px) 500px" srcset="/storage/uploads/public/c/pages/test-100x100.jpg 100w, /storage/uploads/public/c/pages/test-200x200.jpg 200w, /storage/uploads/public/c/pages/test-500x500.jpg 500w" src="/storage/uploads/public/c/pages/test-500x500.jpg"', 'width="500" height="500" sizes="(max-width: 100px) 100px, (max-width: 200px) 200px, (max-width: 500px) 500px" srcset="/storage/uploads/public/c/pages/test-100x100.jpg 100w, /storage/uploads/public/c/pages/test-200x200.jpg 200w, /storage/uploads/public/c/pages/test-500x500.jpg 500w" src="/storage/uploads/public/c/pages/test-500x500.jpg"',
app(CacheManager::class)->get(new MediaPath('pages/test.jpg'), 'original', null), app(CacheManager::class)->get(new StorageMediaPath('pages/test.jpg'), 'original', null),
); );
} }
public function testItThrowsExceptionWhenSizeNotFound() public function testItThrowsExceptionWhenSizeNotFound()
{ {
$this->expectException(ResizerException::class); $this->expectException(ResizerException::class);
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
UploadedFile::fake()->image('test.jpg', 500, 500)->storeAs('uploads/public/c/pages', 'test-500x500.jpg', 'local'); UploadedFile::fake()->image('test.jpg', 500, 500)->storeAs('uploads/public/c/pages', 'test-500x500.jpg', 'local');
dd(app(CacheManager::class)->get(new MediaPath('pages/test.jpg'), 'notfound', null)); dd(app(CacheManager::class)->get(new StorageMediaPath('pages/test.jpg'), 'notfound', null));
} }
public function testFetchPdfImage() public function testFetchPdfImage()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100,200]); Setting::set('breakpoints', [100,200]);
$this->media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf')); $this->media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf'));
@ -68,7 +67,6 @@ class ImageTagTest extends TestCase
public function testItGeneratesLazyLoadingTags() public function testItGeneratesLazyLoadingTags()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100]); Setting::set('breakpoints', [100]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
@ -76,13 +74,12 @@ class ImageTagTest extends TestCase
$this->assertEquals( $this->assertEquals(
'width="100" height="100" sizes="(max-width: 100px) 100px" data-srcset="/storage/uploads/public/c/pages/test-100x100.jpg 100w" data-src="/storage/uploads/public/c/pages/test-100x100.jpg"', 'width="100" height="100" sizes="(max-width: 100px) 100px" data-srcset="/storage/uploads/public/c/pages/test-100x100.jpg 100w" data-src="/storage/uploads/public/c/pages/test-100x100.jpg"',
app(CacheManager::class)->get(new MediaPath('pages/test.jpg'), 'original', null, ['lazy' => true]), app(CacheManager::class)->get(new StorageMediaPath('pages/test.jpg'), 'original', null, ['lazy' => true]),
); );
} }
public function testItGeneratesPngImages() public function testItGeneratesPngImages()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100,200]); Setting::set('breakpoints', [100,200]);
$this->media->put('/pages/test.png', UploadedFile::fake()->image('test.png', 500, 500)->get()); $this->media->put('/pages/test.png', UploadedFile::fake()->image('test.png', 500, 500)->get());
@ -90,13 +87,12 @@ class ImageTagTest extends TestCase
$this->assertEquals( $this->assertEquals(
'width="100" height="100" sizes="(max-width: 100px) 100px" srcset="/storage/uploads/public/c/pages/test-100x100.png 100w" src="/storage/uploads/public/c/pages/test-100x100.png"', 'width="100" height="100" sizes="(max-width: 100px) 100px" srcset="/storage/uploads/public/c/pages/test-100x100.png 100w" src="/storage/uploads/public/c/pages/test-100x100.png"',
app(CacheManager::class)->get(new MediaPath('pages/test.png'), 'original', null), app(CacheManager::class)->get(new StorageMediaPath('pages/test.png'), 'original', null),
); );
} }
public function testItSkipsImagesWithWrongAspectRatio() public function testItSkipsImagesWithWrongAspectRatio()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100,200]); Setting::set('breakpoints', [100,200]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
@ -111,7 +107,6 @@ class ImageTagTest extends TestCase
public function testItCanGenerateAAspectRatio() public function testItCanGenerateAAspectRatio()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1x2']]); Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1x2']]);
Setting::set('breakpoints', [100,200]); Setting::set('breakpoints', [100,200]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
@ -133,7 +128,6 @@ class ImageTagTest extends TestCase
public function testItServesAspectRatiosThatCanBeOnePixelLarger() public function testItServesAspectRatiosThatCanBeOnePixelLarger()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]); Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]);
Setting::set('breakpoints', [640]); Setting::set('breakpoints', [640]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 1920, 899)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 1920, 899)->get());
@ -147,7 +141,6 @@ class ImageTagTest extends TestCase
public function testGenerateCache() public function testGenerateCache()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]); Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]);
Setting::set('breakpoints', [640]); Setting::set('breakpoints', [640]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 1920, 899)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 1920, 899)->get());
@ -159,7 +152,6 @@ class ImageTagTest extends TestCase
public function testPickOriginalImageWhenSvgIsGiven() public function testPickOriginalImageWhenSvgIsGiven()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]); Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]);
Setting::set('breakpoints', [640]); Setting::set('breakpoints', [640]);
$this->media->put('/pages/test.svg', file_get_contents(__DIR__.'/stub/close.svg')); $this->media->put('/pages/test.svg', file_get_contents(__DIR__.'/stub/close.svg'));
@ -174,7 +166,6 @@ class ImageTagTest extends TestCase
public function testNormalizeFilePathForCache() public function testNormalizeFilePathForCache()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]); Setting::set('sizes', [['name' => 'size', 'aspect_ratio' => '1200x280']]);
Setting::set('breakpoints', [640]); Setting::set('breakpoints', [640]);
$this->media->put('/pages/test.svg', file_get_contents(__DIR__.'/stub/close.svg')); $this->media->put('/pages/test.svg', file_get_contents(__DIR__.'/stub/close.svg'));
@ -185,7 +176,6 @@ class ImageTagTest extends TestCase
public function testGenerateSizesAttribute() public function testGenerateSizesAttribute()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100, 200]); Setting::set('breakpoints', [100, 200]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());
@ -199,7 +189,6 @@ class ImageTagTest extends TestCase
public function testItGeneratesOnlySingleImage() public function testItGeneratesOnlySingleImage()
{ {
Setting::set('folders', ['pages']);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', [100]); Setting::set('breakpoints', [100]);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 500, 500)->get());

View File

@ -21,7 +21,7 @@ class MoveTest extends TestCase
public function testItMovesAllVersionsOfAFile() public function testItMovesAllVersionsOfAFile()
{ {
Cache::tags(['resizer', 'resizer.pages/alt/test.jpg'])->set('resizer.original.pages/alt/test.jpg', 'aa'); Cache::tags(['resizer', 'resizer.pages/alt/test.jpg'])->set('resizer.original.pages/alt/test.jpg', 'aa');
Setting::set('folders', ['pages']); Setting::set('folders', [['folder' => '/pages']]);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/alt/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('/pages/alt/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());
@ -36,7 +36,7 @@ class MoveTest extends TestCase
public function testItMovesFilesOnRename() public function testItMovesFilesOnRename()
{ {
Setting::set('folders', ['pages']); Setting::set('folders', [['folder' => '/pages']]);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());
@ -50,7 +50,7 @@ class MoveTest extends TestCase
public function testitDeletesOldAndNewCacheWhenMoving() public function testitDeletesOldAndNewCacheWhenMoving()
{ {
Setting::set('folders', ['pages']); Setting::set('folders', [['folder' => '/pages']]);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());
@ -68,7 +68,7 @@ class MoveTest extends TestCase
public function testRenamePdfHeaderFile() public function testRenamePdfHeaderFile()
{ {
Setting::set('folders', ['pages']); Setting::set('folders', [['folder' => '/pages']]);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf')); $this->media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf'));
@ -83,7 +83,7 @@ class MoveTest extends TestCase
public function testItDoesntMoveOtherFilesInTheSameDirectory() public function testItDoesntMoveOtherFilesInTheSameDirectory()
{ {
Cache::tags(['resizer', 'resizer.pages/test.jpg'])->set('resizer.original.pages/test.jpg', 'aa'); Cache::tags(['resizer', 'resizer.pages/test.jpg'])->set('resizer.original.pages/test.jpg', 'aa');
Setting::set('folders', ['pages']); Setting::set('folders', [['folder' => '/pages']]);
Setting::set('sizes', []); Setting::set('sizes', []);
Setting::set('breakpoints', []); Setting::set('breakpoints', []);
$this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get()); $this->media->put('/pages/test.jpg', UploadedFile::fake()->image('test.jpg', 100, 100)->get());