mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
@@ -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]);
|
||||
|
||||
|
||||
36
tests/Seeders/EggSeeder.php
Normal file
36
tests/Seeders/EggSeeder.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
83
tests/_fixtures/egg-bungeecord.yaml
Normal file
83
tests/_fixtures/egg-bungeecord.yaml
Normal file
File diff suppressed because one or more lines are too long
97
tests/_fixtures/egg-vanilla-minecraft.yaml
Normal file
97
tests/_fixtures/egg-vanilla-minecraft.yaml
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user