Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -7,6 +7,7 @@ use Pterodactyl\Models\Node;
|
|||
use Pterodactyl\Models\Task;
|
||||
use Pterodactyl\Models\User;
|
||||
use InvalidArgumentException;
|
||||
use Pterodactyl\Models\Model;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Database;
|
||||
|
@ -17,6 +18,7 @@ use Pterodactyl\Models\Allocation;
|
|||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Tests\Integration\TestResponse;
|
||||
use Pterodactyl\Tests\Integration\IntegrationTestCase;
|
||||
use Illuminate\Database\Eloquent\Model as EloquentModel;
|
||||
use Pterodactyl\Transformers\Api\Client\BaseClientTransformer;
|
||||
|
||||
abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
||||
|
@ -53,27 +55,24 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
|||
|
||||
/**
|
||||
* Returns a link to the specific resource using the client API.
|
||||
*
|
||||
* @param mixed $model
|
||||
* @param string|null $append
|
||||
*/
|
||||
protected function link($model, $append = null): string
|
||||
protected function link(mixed $model, string $append = null): string
|
||||
{
|
||||
switch (get_class($model)) {
|
||||
case Server::class:
|
||||
$link = "/api/client/servers/{$model->uuid}";
|
||||
$link = "/api/client/servers/$model->uuid";
|
||||
break;
|
||||
case Schedule::class:
|
||||
$link = "/api/client/servers/{$model->server->uuid}/schedules/{$model->id}";
|
||||
$link = "/api/client/servers/{$model->server->uuid}/schedules/$model->id";
|
||||
break;
|
||||
case Task::class:
|
||||
$link = "/api/client/servers/{$model->schedule->server->uuid}/schedules/{$model->schedule->id}/tasks/{$model->id}";
|
||||
$link = "/api/client/servers/{$model->schedule->server->uuid}/schedules/{$model->schedule->id}/tasks/$model->id";
|
||||
break;
|
||||
case Allocation::class:
|
||||
$link = "/api/client/servers/{$model->server->uuid}/network/allocations/{$model->id}";
|
||||
$link = "/api/client/servers/{$model->server->uuid}/network/allocations/$model->id";
|
||||
break;
|
||||
case Backup::class:
|
||||
$link = "/api/client/servers/{$model->server->uuid}/backups/{$model->uuid}";
|
||||
$link = "/api/client/servers/{$model->server->uuid}/backups/$model->uuid";
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException(sprintf('Cannot create link for Model of type %s', class_basename($model)));
|
||||
|
@ -85,10 +84,8 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
|||
/**
|
||||
* Asserts that the data passed through matches the output of the data from the transformer. This
|
||||
* will remove the "relationships" key when performing the comparison.
|
||||
*
|
||||
* @param \Pterodactyl\Models\Model|\Illuminate\Database\Eloquent\Model $model
|
||||
*/
|
||||
protected function assertJsonTransformedWith(array $data, $model)
|
||||
protected function assertJsonTransformedWith(array $data, Model|EloquentModel $model)
|
||||
{
|
||||
$reflect = new ReflectionClass($model);
|
||||
$transformer = sprintf('\\Pterodactyl\\Transformers\\Api\\Client\\%sTransformer', $reflect->getShortName());
|
||||
|
|
Reference in a new issue