oc-resizer-plugin/tests/TestCase.php

48 lines
1.1 KiB
PHP

<?php
namespace Aweos\Resizer\Tests;
use Aweos\Resizer\Models\Setting;
use MediaLibrary;
use PluginTestCase;
use Storage;
use System\Classes\PluginManager;
class TestCase extends PluginTestCase
{
public MediaLibrary $media;
public function setUp(): void
{
parent::setUp();
Setting::set('queue', 'default');
$this->media = MediaLibrary::instance();
$pluginManager = PluginManager::instance();
$pluginManager->registerAll(true);
$pluginManager->bootAll(true);
}
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);
}
}