oc-resizer-plugin/tests/SlugTest.php

60 lines
1.6 KiB
PHP
Raw Normal View History

2022-03-22 22:54:57 +01:00
<?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');
}
}