2021-09-06 02:31:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Aweos\Resizer\Tests;
|
|
|
|
|
2021-11-01 12:52:45 +01:00
|
|
|
use Aweos\Resizer\Models\Setting;
|
2021-12-17 01:29:15 +01:00
|
|
|
use MediaLibrary;
|
2021-09-06 02:31:27 +02:00
|
|
|
use PluginTestCase;
|
|
|
|
use Storage;
|
|
|
|
use System\Classes\PluginManager;
|
|
|
|
|
|
|
|
class TestCase extends PluginTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
public MediaLibrary $media;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2021-11-01 12:52:45 +01:00
|
|
|
Setting::set('queue', 'default');
|
2021-09-06 02:31:27 +02:00
|
|
|
$this->media = MediaLibrary::instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assertHasFile($file): void
|
|
|
|
{
|
|
|
|
Storage::disk('local')->assertExists("uploads/public/c/{$this->normalizeFilePath($file)}");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assertDoesntHaveFile($file): void
|
|
|
|
{
|
|
|
|
Storage::disk('local')->assertMissing("uploads/public/c/{$this->normalizeFilePath($file)}");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function assertFileCount($count, $dir): void
|
|
|
|
{
|
|
|
|
$this->assertCount($count, Storage::disk('local')->files("uploads/public/c/{$this->normalizeFilePath($dir)}"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function normalizeFilePath(string $path): string
|
|
|
|
{
|
|
|
|
return preg_replace('|^/*|', '', $path);
|
|
|
|
}
|
|
|
|
}
|