60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Aweos\Resizer\Tests;
|
|
|
|
use Event;
|
|
use Illuminate\Http\UploadedFile;
|
|
use MediaLibrary;
|
|
use Storage;
|
|
|
|
class SlugTest extends TestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Storage::fake('local');
|
|
$this->media = MediaLibrary::instance();
|
|
}
|
|
|
|
public function testDontRenameFolderIfSluggingIsNotNeeded(): void
|
|
{
|
|
$file = UploadedFile::fake()->image('test.jpg', 500, 600);
|
|
$this->media->makeFolder('testbb');
|
|
|
|
Event::fire('media.folder.create', [null, '//testbb', null]);
|
|
|
|
Storage::disk('local')->assertExists('media/testbb');
|
|
}
|
|
|
|
public function testRenameFolder(): void
|
|
{
|
|
$file = UploadedFile::fake()->image('test.jpg', 500, 600);
|
|
$this->media->makeFolder('test bb');
|
|
|
|
Event::fire('media.folder.create', [null, '//test bb', null]);
|
|
|
|
Storage::disk('local')->assertExists('media/test-bb');
|
|
Storage::disk('local')->assertMissing('media/test bb');
|
|
}
|
|
|
|
public function testRenameSubfolder(): void
|
|
{
|
|
$file = UploadedFile::fake()->image('test.jpg', 500, 600);
|
|
$this->media->makeFolder('test/aa bb');
|
|
|
|
Event::fire('media.folder.create', [null, '/test/aa bb', null]);
|
|
|
|
Storage::disk('local')->assertExists('media/test/aa-bb');
|
|
}
|
|
|
|
public function testRenameSubfolderWithDoubleSlash(): void
|
|
{
|
|
$file = UploadedFile::fake()->image('test.jpg', 500, 600);
|
|
$this->media->makeFolder('test/aa bb');
|
|
|
|
Event::fire('media.folder.create', [null, '//test/aa bb', null]);
|
|
|
|
Storage::disk('local')->assertExists('media/test/aa-bb');
|
|
}
|
|
}
|