Add test coverage for startup modification

This commit is contained in:
Dane Everitt 2020-10-08 20:38:21 -07:00
parent d087bebc93
commit 7a643beee0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 148 additions and 19 deletions

View file

@ -2,6 +2,7 @@
namespace Tests\Traits\Integration;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Nest;
use Pterodactyl\Models\Node;
@ -74,4 +75,27 @@ trait CreatesTestModels
'location', 'user', 'node', 'allocation', 'nest', 'egg',
])->findOrFail($server->id);
}
/**
* Clones a given egg allowing us to make modifications that don't affect other
* tests that rely on the egg existing in the correct state.
*
* @param \Pterodactyl\Models\Egg $egg
* @return \Pterodactyl\Models\Egg
*/
protected function cloneEggAndVariables(Egg $egg): Egg
{
$model = $egg->replicate(['id', 'uuid']);
$model->uuid = Uuid::uuid4()->toString();
$model->push();
/** @var \Pterodactyl\Models\Egg $model */
$model = $model->fresh();
foreach ($egg->variables as $variable) {
$variable->replicate(['id', 'egg_id'])->forceFill(['egg_id' => $model->id])->push();
}
return $model->fresh();
}
}