Path: blob/1.0-develop/tests/Integration/Api/Client/Server/ResourceUtilizationControllerTest.php
7461 views
<?php12namespace Pterodactyl\Tests\Integration\Api\Client\Server;34use Pterodactyl\Models\Permission;5use Pterodactyl\Repositories\Wings\DaemonServerRepository;6use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;78class ResourceUtilizationControllerTest extends ClientApiIntegrationTestCase9{10/**11* Test that the resource utilization for a server is returned in the expected format.12*/13public function testServerResourceUtilizationIsReturned()14{15$service = \Mockery::mock(DaemonServerRepository::class);16$this->app->instance(DaemonServerRepository::class, $service);1718[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);1920$service->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {21return $server->uuid === $value->uuid;22}))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]);2324$response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/resources");2526$response->assertOk();27$response->assertJson([28'object' => 'stats',29'attributes' => [30'current_state' => 'stopped',31'is_suspended' => false,32'resources' => [33'memory_bytes' => 0,34'cpu_absolute' => 0,35'disk_bytes' => 0,36'network_rx_bytes' => 0,37'network_tx_bytes' => 0,38],39],40]);41}42}434445