Add test coverage for creating tasks
This commit is contained in:
parent
b9a451b528
commit
28c5729e48
8 changed files with 243 additions and 5 deletions
|
@ -6,11 +6,14 @@ use Carbon\Carbon;
|
|||
use ReflectionClass;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Task;
|
||||
use Pterodactyl\Models\User;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Model;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Pterodactyl\Models\Schedule;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Tests\Integration\IntegrationTestCase;
|
||||
use Pterodactyl\Transformers\Api\Client\BaseClientTransformer;
|
||||
|
@ -41,6 +44,33 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
|||
CarbonImmutable::setTestNow(Carbon::now());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the specific resource using the client API.
|
||||
*
|
||||
* @param mixed $model
|
||||
* @param string|null $append
|
||||
* @return string
|
||||
*/
|
||||
protected function link($model, $append = null): string
|
||||
{
|
||||
Assert::isInstanceOfAny($model, [Server::class, Schedule::class, Task::class]);
|
||||
|
||||
$link = '';
|
||||
switch (get_class($model)) {
|
||||
case Server::class:
|
||||
$link = "/api/client/servers/{$model->uuid}";
|
||||
break;
|
||||
case Schedule::class:
|
||||
$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}";
|
||||
break;
|
||||
}
|
||||
|
||||
return $link . ($append ? '/' . ltrim($append, '/') : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a user and a server for that user. If an array of permissions is passed it
|
||||
* is assumed that the user is actually a subuser of the server.
|
||||
|
|
Reference in a new issue