Add test cases for sending a command to a server
This commit is contained in:
parent
4cb95d8063
commit
8cfdb3acce
8 changed files with 160 additions and 46 deletions
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Tests\Integration\Api\Client;
|
||||
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Pterodactyl\Tests\Integration\IntegrationTestCase;
|
||||
|
||||
abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
|
||||
{
|
||||
/**
|
||||
* Cleanup after running tests.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Server::query()->forceDelete();
|
||||
Node::query()->forceDelete();
|
||||
Location::query()->forceDelete();
|
||||
User::query()->forceDelete();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param string[] $permissions
|
||||
* @return array
|
||||
*/
|
||||
protected function generateTestAccount(array $permissions = []): array
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
if (empty($permissions)) {
|
||||
return [$user, $this->createServerModel(['user_id' => $user->id])];
|
||||
}
|
||||
|
||||
$server = $this->createServerModel();
|
||||
|
||||
Subuser::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'server_id' => $server->id,
|
||||
'permissions' => $permissions,
|
||||
]);
|
||||
|
||||
return [$user, $server];
|
||||
}
|
||||
}
|
Reference in a new issue