Add Eggs to Installer (#2004)

Co-authored-by: Boy132 <mail@boy132.de>
This commit is contained in:
Charles
2025-12-29 17:24:02 -05:00
committed by GitHub
parent 976cb00c0d
commit bed9dbeb2b
21 changed files with 209 additions and 1701 deletions

View File

@@ -70,7 +70,7 @@ class StartupModificationServiceTest extends IntegrationTestCase
public function test_server_is_properly_modified_as_admin_user(): void
{
/** @var \App\Models\Egg $nextEgg */
$nextEgg = Egg::query()->findOrFail(6);
$nextEgg = Egg::query()->findOrFail(2);
$server = $this->createServerModel(['egg_id' => 1]);

View File

@@ -0,0 +1,36 @@
<?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);
}
}
}

View File

@@ -2,8 +2,10 @@
namespace App\Tests;
use App\Tests\Seeders\EggSeeder;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Exception;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Spatie\Permission\PermissionRegistrar;
@@ -35,6 +37,13 @@ abstract class TestCase extends BaseTestCase
$this->setKnownUuidFactory();
$this->app->make(PermissionRegistrar::class)->forgetCachedPermissions();
try {
$seeder = new EggSeeder();
$seeder->run();
} catch (Exception) {
// Don't fail all tests if the fixture/ seeder isn't present or import fails.
}
}
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long