Files
panel-pelican-dev/tests/Seeders/EggSeeder.php
Charles bed9dbeb2b Add Eggs to Installer (#2004)
Co-authored-by: Boy132 <mail@boy132.de>
2025-12-29 17:24:02 -05:00

37 lines
916 B
PHP

<?php
namespace App\Tests\Seeders;
use App\Exceptions\Service\InvalidFileUploadException;
use App\Services\Eggs\Sharing\EggImporterService;
use DirectoryIterator;
use Illuminate\Http\UploadedFile;
use Throwable;
class EggSeeder
{
/**
* @throws InvalidFileUploadException|Throwable
*/
public function run(): void
{
// @phpstan-ignore myCustomRules.forbiddenGlobalFunctions
$importer = app(EggImporterService::class);
$path = base_path('tests/_fixtures');
$files = new DirectoryIterator($path);
/** @var DirectoryIterator $file */
foreach ($files as $file) {
if (!$file->isFile() || !$file->isReadable()) {
continue;
}
$filePath = $file->getRealPath();
$uploaded = new UploadedFile($filePath, basename($filePath));
$importer->fromFile($uploaded);
}
}
}