Implement 'includeTotal' parameter across multiple API endpoints to control total count in responses, ensuring consistent behavior in session, log, and membership retrievals.

This commit is contained in:
shimon
2025-10-20 18:18:17 +03:00
parent 55a33c135c
commit fb4e3e1b9d
15 changed files with 249 additions and 22 deletions
+6 -4
View File
@@ -553,12 +553,13 @@ App::get('/v1/account/sessions')
],
contentType: ContentType::JSON,
))
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('user')
->inject('locale')
->inject('store')
->inject('proofForToken')
->action(function (Response $response, Document $user, Locale $locale, Store $store, ProofsToken $proofForToken) {
->action(function (bool $includeTotal, Response $response, Document $user, Locale $locale, Store $store, ProofsToken $proofForToken) {
$sessions = $user->getAttribute('sessions', []);
@@ -576,7 +577,7 @@ App::get('/v1/account/sessions')
$response->dynamic(new Document([
'sessions' => $sessions,
'total' => count($sessions),
'total' => $includeTotal ? count($sessions) : 0,
]), Response::MODEL_SESSION_LIST);
});
@@ -2879,12 +2880,13 @@ App::get('/v1/account/logs')
contentType: ContentType::JSON,
))
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('user')
->inject('locale')
->inject('geodb')
->inject('dbForProject')
->action(function (array $queries, Response $response, Document $user, Locale $locale, Reader $geodb, Database $dbForProject) {
->action(function (array $queries, bool $includeTotal, Response $response, Document $user, Locale $locale, Reader $geodb, Database $dbForProject) {
try {
$queries = Query::parseQueries($queries);
@@ -2929,7 +2931,7 @@ App::get('/v1/account/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByUser($user->getSequence(), $queries),
'total' => $includeTotal ? $audit->countLogsByUser($user->getSequence(), $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
+12 -8
View File
@@ -1054,11 +1054,12 @@ App::get('/v1/messaging/providers/:providerId/logs')
))
->param('providerId', '', new UID(), 'Provider ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $providerId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $providerId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$provider = $dbForProject->getDocument('providers', $providerId);
if ($provider->isEmpty()) {
@@ -1126,7 +1127,7 @@ App::get('/v1/messaging/providers/:providerId/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByResource($resource, $queries),
'total' => $includeTotal ? $audit->countLogsByResource($resource, $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@@ -2362,11 +2363,12 @@ App::get('/v1/messaging/topics/:topicId/logs')
))
->param('topicId', '', new UID(), 'Topic ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $topicId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $topicId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$topic = $dbForProject->getDocument('topics', $topicId);
if ($topic->isEmpty()) {
@@ -2435,7 +2437,7 @@ App::get('/v1/messaging/topics/:topicId/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByResource($resource, $queries),
'total' => $includeTotal ? $audit->countLogsByResource($resource, $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@@ -2783,11 +2785,12 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs')
))
->param('subscriberId', '', new UID(), 'Subscriber ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $subscriberId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $subscriberId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$subscriber = $dbForProject->getDocument('subscribers', $subscriberId);
if ($subscriber->isEmpty()) {
@@ -2856,7 +2859,7 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByResource($resource, $queries),
'total' => $includeTotal ? $audit->countLogsByResource($resource, $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@@ -3582,11 +3585,12 @@ App::get('/v1/messaging/messages/:messageId/logs')
))
->param('messageId', '', new UID(), 'Message ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $messageId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $messageId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$message = $dbForProject->getDocument('messages', $messageId);
if ($message->isEmpty()) {
@@ -3655,7 +3659,7 @@ App::get('/v1/messaging/messages/:messageId/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByResource($resource, $queries),
'total' => $includeTotal ? $audit->countLogsByResource($resource, $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
+3 -2
View File
@@ -1445,11 +1445,12 @@ App::get('/v1/teams/:teamId/logs')
))
->param('teamId', '', new UID(), 'Team ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $teamId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $teamId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$team = $dbForProject->getDocument('teams', $teamId);
@@ -1518,7 +1519,7 @@ App::get('/v1/teams/:teamId/logs')
}
}
$response->dynamic(new Document([
'total' => $audit->countLogsByResource($resource, $queries),
'total' => $includeTotal ? $audit->countLogsByResource($resource, $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
+9 -6
View File
@@ -826,10 +826,11 @@ App::get('/v1/users/:userId/sessions')
]
))
->param('userId', '', new UID(), 'User ID.')
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->action(function (string $userId, Response $response, Database $dbForProject, Locale $locale) {
->action(function (string $userId, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale) {
$user = $dbForProject->getDocument('users', $userId);
@@ -851,7 +852,7 @@ App::get('/v1/users/:userId/sessions')
$response->dynamic(new Document([
'sessions' => $sessions,
'total' => count($sessions),
'total' => $includeTotal ? count($sessions) : 0,
]), Response::MODEL_SESSION_LIST);
});
@@ -875,9 +876,10 @@ App::get('/v1/users/:userId/memberships')
->param('userId', '', new UID(), 'User ID.')
->param('queries', [], new Memberships(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Memberships::ALLOWED_ATTRIBUTES), true)
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->action(function (string $userId, array $queries, string $search, Response $response, Database $dbForProject) {
->action(function (string $userId, array $queries, string $search, bool $includeTotal, Response $response, Database $dbForProject) {
$user = $dbForProject->getDocument('users', $userId);
@@ -911,7 +913,7 @@ App::get('/v1/users/:userId/memberships')
$response->dynamic(new Document([
'memberships' => $memberships,
'total' => count($memberships),
'total' => $includeTotal ? count($memberships) : 0,
]), Response::MODEL_MEMBERSHIP_LIST);
});
@@ -934,11 +936,12 @@ App::get('/v1/users/:userId/logs')
))
->param('userId', '', new UID(), 'User ID.')
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->inject('dbForProject')
->inject('locale')
->inject('geodb')
->action(function (string $userId, array $queries, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
->action(function (string $userId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Locale $locale, Reader $geodb) {
$user = $dbForProject->getDocument('users', $userId);
@@ -1007,7 +1010,7 @@ App::get('/v1/users/:userId/logs')
}
$response->dynamic(new Document([
'total' => $audit->countLogsByUser($user->getSequence(), $queries),
'total' => $includeTotal ? $audit->countLogsByUser($user->getSequence(), $queries) : 0,
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@@ -12,6 +12,7 @@ use Utopia\Database\Document;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Boolean;
use Utopia\Validator\Range;
use Utopia\Validator\WhiteList;
@@ -52,11 +53,12 @@ class XList extends Base
->param('useCases', [], new ArrayList(new WhiteList(['dev-tools','starter','databases','ai','messaging','utilities']), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true)
->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true)
->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true)
->param('includeTotal', true, new Boolean(), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
->inject('response')
->callback($this->action(...));
}
public function action(array $runtimes, array $usecases, int $limit, int $offset, Response $response)
public function action(array $runtimes, array $usecases, int $limit, int $offset, bool $includeTotal, Response $response)
{
$templates = Config::getParam('templates-function', []);
@@ -76,7 +78,7 @@ class XList extends Base
return $b['score'] <=> $a['score'];
});
$total = \count($templates);
$total = $includeTotal ? \count($templates) : 0;
$templates = \array_slice($templates, $offset, $limit);
$response->dynamic(new Document([
'templates' => $templates,
@@ -236,6 +236,25 @@ class AccountCustomClientTest extends Scope
$this->assertEquals($sessionId, $response['body']['sessions'][0]['$id']);
$this->assertEmpty($response['body']['sessions'][0]['secret']);
/**
* Test for SUCCESS with includeTotal=false
*/
$sessionsWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
]), [
'includeTotal' => false
]);
$this->assertEquals($sessionsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($sessionsWithIncludeTotalFalse['body']);
$this->assertIsArray($sessionsWithIncludeTotalFalse['body']['sessions']);
$this->assertIsInt($sessionsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $sessionsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($sessionsWithIncludeTotalFalse['body']['sessions']));
$this->assertEquals('Windows', $response['body']['sessions'][0]['osName']);
$this->assertEquals('WIN', $response['body']['sessions'][0]['osCode']);
$this->assertEquals('10', $response['body']['sessions'][0]['osVersion']);
@@ -961,6 +961,24 @@ trait DatabasesBase
$this->assertEquals(200, $attributes['headers']['status-code']);
$this->assertEquals(12, $attributes['body']['total']);
/**
* Test for SUCCESS with includeTotal=false
*/
$attributesWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'includeTotal' => false
]);
$this->assertEquals($attributesWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($attributesWithIncludeTotalFalse['body']);
$this->assertIsArray($attributesWithIncludeTotalFalse['body']['attributes']);
$this->assertIsInt($attributesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $attributesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($attributesWithIncludeTotalFalse['body']['attributes']));
$attributes = $attributes['body']['attributes'];
$this->assertIsArray($attributes);
$this->assertCount(12, $attributes);
@@ -55,6 +55,23 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals($test1['body']['$id'], $databases['body']['databases'][0]['$id']);
$this->assertEquals($test2['body']['$id'], $databases['body']['databases'][1]['$id']);
/**
* Test for SUCCESS with includeTotal=false
*/
$databasesWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/databases', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($databasesWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($databasesWithIncludeTotalFalse['body']);
$this->assertIsArray($databasesWithIncludeTotalFalse['body']['databases']);
$this->assertIsInt($databasesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $databasesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($databasesWithIncludeTotalFalse['body']['databases']));
$base = array_reverse($databases['body']['databases']);
$databases = $this->client->call(Client::METHOD_GET, '/databases', array_merge([
@@ -395,6 +412,23 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals($test2['body']['$id'], $collections['body']['collections'][1]['$id']);
$this->assertEquals($test1['body']['enabled'], $collections['body']['collections'][0]['enabled']);
/**
* Test for SUCCESS with includeTotal=false
*/
$collectionsWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($collectionsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($collectionsWithIncludeTotalFalse['body']);
$this->assertIsArray($collectionsWithIncludeTotalFalse['body']['collections']);
$this->assertIsInt($collectionsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $collectionsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($collectionsWithIncludeTotalFalse['body']['collections']));
$base = array_reverse($collections['body']['collections']);
$collections = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections', array_merge([
@@ -4548,6 +4582,23 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals(200, $documents['headers']['status-code']);
$this->assertEquals(10, $documents['body']['total']);
/**
* Test for SUCCESS with includeTotal=false
*/
$documentsWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['$id'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($documentsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($documentsWithIncludeTotalFalse['body']);
$this->assertIsArray($documentsWithIncludeTotalFalse['body']['documents']);
$this->assertIsInt($documentsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $documentsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($documentsWithIncludeTotalFalse['body']['documents']));
$returnedDocuments = $response['body']['documents'];
$refetchedDocuments = $documents['body']['documents'];
@@ -55,6 +55,23 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals($test1['body']['$id'], $databases['body']['databases'][0]['$id']);
$this->assertEquals($test2['body']['$id'], $databases['body']['databases'][1]['$id']);
/**
* Test for SUCCESS with includeTotal=false
*/
$databasesWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/tablesdb', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($databasesWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($databasesWithIncludeTotalFalse['body']);
$this->assertIsArray($databasesWithIncludeTotalFalse['body']['databases']);
$this->assertIsInt($databasesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $databasesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($databasesWithIncludeTotalFalse['body']['databases']));
$base = array_reverse($databases['body']['databases']);
$databases = $this->client->call(Client::METHOD_GET, '/tablesdb', array_merge([
@@ -376,6 +376,23 @@ class FunctionsCustomClientTest extends Scope
$this->assertGreaterThan(0, $templates['body']['total']);
$this->assertIsArray($templates['body']['templates']);
/**
* Test for SUCCESS with includeTotal=false
*/
$templatesWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/functions/templates', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($templatesWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($templatesWithIncludeTotalFalse['body']);
$this->assertIsArray($templatesWithIncludeTotalFalse['body']['templates']);
$this->assertIsInt($templatesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $templatesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($templatesWithIncludeTotalFalse['body']['templates']));
foreach ($templates['body']['templates'] as $template) {
$this->assertArrayHasKey('name', $template);
$this->assertArrayHasKey('id', $template);
@@ -418,6 +418,18 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertEquals(1, $deployments['body']['total']);
/**
* Test for SUCCESS with includeTotal=false
*/
$deploymentsWithIncludeTotalFalse = $this->listDeployments($functionId, ['includeTotal' => false]);
$this->assertEquals($deploymentsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($deploymentsWithIncludeTotalFalse['body']);
$this->assertIsArray($deploymentsWithIncludeTotalFalse['body']['deployments']);
$this->assertIsInt($deploymentsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $deploymentsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($deploymentsWithIncludeTotalFalse['body']['deployments']));
$lastDeployment = $deployments['body']['deployments'][0];
$this->assertNotEmpty($lastDeployment['$id']);
@@ -1004,6 +1016,18 @@ class FunctionsCustomServerTest extends Scope
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($data['deploymentId'], $executions['body']['executions'][0]['deploymentId']);
/**
* Test for SUCCESS with includeTotal=false
*/
$executionsWithIncludeTotalFalse = $this->listExecutions($data['functionId'], ['includeTotal' => false]);
$this->assertEquals($executionsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($executionsWithIncludeTotalFalse['body']);
$this->assertIsArray($executionsWithIncludeTotalFalse['body']['executions']);
$this->assertIsInt($executionsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $executionsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($executionsWithIncludeTotalFalse['body']['executions']));
$executions = $this->listExecutions($data['functionId'], [
'queries' => [
Query::equal('deploymentId', [$data['deploymentId']])->toString(),
@@ -633,6 +633,24 @@ trait MessagingBase
$this->assertEquals(1, $response['body']['total']);
}
/**
* Test for SUCCESS with includeTotal=false
*/
$subscribersWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $data['topicId'] . '/subscribers', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]), [
'includeTotal' => false
]);
$this->assertEquals($subscribersWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($subscribersWithIncludeTotalFalse['body']);
$this->assertIsArray($subscribersWithIncludeTotalFalse['body']['subscribers']);
$this->assertIsInt($subscribersWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $subscribersWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($subscribersWithIncludeTotalFalse['body']['subscribers']));
return $data;
}
@@ -379,6 +379,23 @@ trait StorageBase
$this->assertGreaterThan(0, $files['body']['total']);
$this->assertGreaterThan(0, count($files['body']['files']));
/**
* Test for SUCCESS with includeTotal=false
*/
$filesWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($filesWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($filesWithIncludeTotalFalse['body']);
$this->assertIsArray($filesWithIncludeTotalFalse['body']['files']);
$this->assertIsInt($filesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $filesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($filesWithIncludeTotalFalse['body']['files']));
$files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
+17
View File
@@ -322,6 +322,23 @@ trait TeamsBase
$this->assertEquals(400, $response['headers']['status-code']);
/**
* Test for SUCCESS with includeTotal=false
*/
$teamsWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($teamsWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($teamsWithIncludeTotalFalse['body']);
$this->assertIsArray($teamsWithIncludeTotalFalse['body']['teams']);
$this->assertIsInt($teamsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $teamsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($teamsWithIncludeTotalFalse['body']['teams']));
return [];
}
+17
View File
@@ -798,6 +798,23 @@ trait UsersBase
$this->assertIsInt($users['body']['total']);
$this->assertGreaterThan(0, $users['body']['total']);
/**
* Test for SUCCESS with includeTotal=false
*/
$usersWithIncludeTotalFalse = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'includeTotal' => false
]);
$this->assertEquals($usersWithIncludeTotalFalse['headers']['status-code'], 200);
$this->assertIsArray($usersWithIncludeTotalFalse['body']);
$this->assertIsArray($usersWithIncludeTotalFalse['body']['users']);
$this->assertIsInt($usersWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $usersWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($usersWithIncludeTotalFalse['body']['users']));
/**
* Test for FAILURE
*/