Update egg import/update logic to all use the same pathwaus
This commit is contained in:
parent
6554164252
commit
cca0010a00
12 changed files with 271 additions and 334 deletions
|
@ -4,7 +4,6 @@ namespace Pterodactyl\Tests\Traits\Integration;
|
|||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
@ -52,20 +51,17 @@ trait CreatesTestModels
|
|||
$attributes['allocation_id'] = $allocation->id;
|
||||
}
|
||||
|
||||
if (!isset($attributes['nest_id'])) {
|
||||
/** @var \Pterodactyl\Models\Nest $nest */
|
||||
$nest = Nest::with('eggs')->first();
|
||||
$attributes['nest_id'] = $nest->id;
|
||||
if (empty($attributes['egg_id'])) {
|
||||
$egg = !empty($attributes['nest_id'])
|
||||
? Egg::query()->where('nest_id', $attributes['nest_id'])->firstOrFail()
|
||||
: $this->getBungeecordEgg();
|
||||
|
||||
if (!isset($attributes['egg_id'])) {
|
||||
$attributes['egg_id'] = $nest->getRelation('eggs')->first()->id;
|
||||
}
|
||||
$attributes['egg_id'] = $egg->id;
|
||||
$attributes['nest_id'] = $egg->nest_id;
|
||||
}
|
||||
|
||||
if (!isset($attributes['egg_id'])) {
|
||||
/** @var \Pterodactyl\Models\Egg $egg */
|
||||
$egg = Egg::where('nest_id', $attributes['nest_id'])->first();
|
||||
$attributes['egg_id'] = $egg->id;
|
||||
if (empty($attributes['nest_id'])) {
|
||||
$attributes['nest_id'] = Egg::query()->findOrFail($attributes['egg_id'])->nest_id;
|
||||
}
|
||||
|
||||
unset($attributes['user_id'], $attributes['location_id']);
|
||||
|
@ -99,4 +95,13 @@ trait CreatesTestModels
|
|||
|
||||
return $model->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Most every test just assumes it is using Bungeecord — this is the critical
|
||||
* egg model for all tests unless specified otherwise.
|
||||
*/
|
||||
private function getBungeecordEgg()
|
||||
{
|
||||
return Egg::query()->where('author', 'support@pterodactyl.io')->where('name', 'Bungeecord')->firstOrFail();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue