1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00
appwrite/tests/e2e/Services/Users/UsersConsoleClientTest.php
2023-02-05 23:06:32 +02:00

47 lines
1.3 KiB
PHP

<?php
namespace Tests\E2E\Services\Users;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Client;
use Tests\E2E\Scopes\SideConsole;
class UsersConsoleClientTest extends Scope
{
use ProjectCustom;
use SideConsole;
public function testGetUsersUsage()
{
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '32h',
]);
$this->assertEquals($response['headers']['status-code'], 400);
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'range' => '24h',
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(count($response['body']), 3);
$this->assertEquals($response['body']['range'], '24h');
$this->assertIsArray($response['body']['usersTotal']);
$this->assertIsArray($response['body']['sessionsTotal']);
}
}