1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

Refactored 'sum' to 'total'

This commit is contained in:
Matej Baco 2022-02-27 10:57:09 +01:00
parent 7f0c3250cc
commit 56bf7a51df
30 changed files with 210 additions and 198 deletions

View file

@ -1426,7 +1426,7 @@ $collections = [
'filters' => [],
],
[
'$id' => 'sum',
'$id' => 'total',
'type' => Database::VAR_INTEGER,
'format' => '',
'size' => 0,

View file

@ -80,11 +80,11 @@ App::post('/v1/account')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0) {
$sum = $dbForProject->count('users', [
$total = $dbForProject->count('users', [
new Query('deleted', Query::TYPE_EQUAL, [false]),
], APP_LIMIT_USERS);
if ($sum >= $limit) {
if ($total >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501, Exception::USER_COUNT_EXCEEDED);
}
}
@ -483,9 +483,9 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0) {
$sum = $dbForProject->count('users', [ new Query('deleted', Query::TYPE_EQUAL, [false]),], APP_LIMIT_USERS);
$total = $dbForProject->count('users', [ new Query('deleted', Query::TYPE_EQUAL, [false]),], APP_LIMIT_USERS);
if ($sum >= $limit) {
if ($total >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501, Exception::USER_COUNT_EXCEEDED);
}
}
@ -656,11 +656,11 @@ App::post('/v1/account/sessions/magic-url')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0) {
$sum = $dbForProject->count('users', [
$total = $dbForProject->count('users', [
new Query('deleted', Query::TYPE_EQUAL, [false]),
], APP_LIMIT_USERS);
if ($sum >= $limit) {
if ($total >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501, Exception::USER_COUNT_EXCEEDED);
}
}
@ -928,11 +928,11 @@ App::post('/v1/account/sessions/anonymous')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0) {
$sum = $dbForProject->count('users', [
$total = $dbForProject->count('users', [
new Query('deleted', Query::TYPE_EQUAL, [false]),
], APP_LIMIT_USERS);
if ($sum >= $limit) {
if ($total >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501, Exception::USER_COUNT_EXCEEDED);
}
}
@ -1163,7 +1163,7 @@ App::get('/v1/account/sessions')
;
$response->dynamic(new Document([
'sessions' => $sessions,
'sum' => count($sessions),
'total' => count($sessions),
]), Response::MODEL_SESSION_LIST);
});
@ -1249,7 +1249,7 @@ App::get('/v1/account/logs')
;
$response->dynamic(new Document([
'sum' => $audit->countLogsByUserAndEvents($user->getId(), $auditEvents),
'total' => $audit->countLogsByUserAndEvents($user->getId(), $auditEvents),
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@ -1825,7 +1825,7 @@ App::delete('/v1/account/sessions')
$events
->setParam('eventData', $response->output(new Document([
'sessions' => $sessions,
'sum' => $numOfSessions,
'total' => $numOfSessions,
]), Response::MODEL_SESSION_LIST))
;

View file

@ -239,7 +239,7 @@ App::get('/v1/database/collections')
$response->dynamic(new Document([
'collections' => $dbForProject->find('collections', $queries, $limit, $offset, [], [$orderType], $cursorCollection ?? null, $cursorDirection),
'sum' => $dbForProject->count('collections', $queries, APP_LIMIT_COUNT),
'total' => $dbForProject->count('collections', $queries, APP_LIMIT_COUNT),
]), Response::MODEL_COLLECTION_LIST);
});
@ -569,7 +569,7 @@ App::get('/v1/database/collections/:collectionId/logs')
}
$response->dynamic(new Document([
'sum' => $audit->countLogsByResource($resource),
'total' => $audit->countLogsByResource($resource),
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});
@ -1146,7 +1146,7 @@ App::get('/v1/database/collections/:collectionId/attributes')
$usage->setParam('database.collections.read', 1);
$response->dynamic(new Document([
'sum' => \count($attributes),
'total' => \count($attributes),
'attributes' => $attributes
]), Response::MODEL_ATTRIBUTE_LIST);
});
@ -1437,7 +1437,7 @@ App::get('/v1/database/collections/:collectionId/indexes')
$usage->setParam('database.collections.read', 1);
$response->dynamic(new Document([
'sum' => \count($indexes),
'total' => \count($indexes),
'indexes' => $indexes,
]), Response::MODEL_INDEX_LIST);
});
@ -1753,10 +1753,10 @@ App::get('/v1/database/collections/:collectionId/documents')
if ($collection->getAttribute('permission') === 'collection') {
/** @var Document[] $documents */
$documents = Authorization::skip(fn() => $dbForProject->find('collection_' . $collectionId, $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection));
$sum = Authorization::skip(fn() => $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT));
$total = Authorization::skip(fn() => $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT));
} else {
$documents = $dbForProject->find('collection_' . $collectionId, $queries, $limit, $offset, $orderAttributes, $orderTypes, $cursorDocument ?? null, $cursorDirection);
$sum = $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT);
$total = $dbForProject->count('collection_' . $collectionId, $queries, APP_LIMIT_COUNT);
}
/**
@ -1770,7 +1770,7 @@ App::get('/v1/database/collections/:collectionId/documents')
;
$response->dynamic(new Document([
'sum' => $sum,
'total' => $total,
'documents' => $documents,
]), Response::MODEL_DOCUMENT_LIST);
});
@ -1927,7 +1927,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId/logs')
}
}
$response->dynamic(new Document([
'sum' => $audit->countLogsByResource($resource),
'total' => $audit->countLogsByResource($resource),
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});

View file

@ -118,7 +118,7 @@ App::get('/v1/functions')
$response->dynamic(new Document([
'functions' => $dbForProject->find('functions', $queries, $limit, $offset, [], [$orderType], $cursorFunction ?? null, $cursorDirection),
'sum' => $dbForProject->count('functions', $queries, APP_LIMIT_COUNT),
'total' => $dbForProject->count('functions', $queries, APP_LIMIT_COUNT),
]), Response::MODEL_FUNCTION_LIST);
});
@ -145,7 +145,7 @@ App::get('/v1/functions/runtimes')
}, array_keys($runtimes));
$response->dynamic(new Document([
'sum' => count($runtimes),
'total' => count($runtimes),
'runtimes' => $runtimes
]), Response::MODEL_RUNTIME_LIST);
});
@ -686,7 +686,7 @@ App::get('/v1/functions/:functionId/deployments')
$queries[] = new Query('resourceType', Query::TYPE_EQUAL, ['functions']);
$results = $dbForProject->find('deployments', $queries, $limit, $offset, [], [$orderType], $cursorDeployment ?? null, $cursorDirection);
$sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT);
$total = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT);
foreach ($results as $result) {
$build = $dbForProject->getDocument('builds', $result->getAttribute('buildId', ''));
@ -697,7 +697,7 @@ App::get('/v1/functions/:functionId/deployments')
$response->dynamic(new Document([
'deployments' => $results,
'sum' => $sum,
'total' => $total,
]), Response::MODEL_DEPLOYMENT_LIST);
});
@ -1020,11 +1020,11 @@ App::get('/v1/functions/:functionId/executions')
}
$results = $dbForProject->find('executions', $queries, $limit, $offset, [], [Database::ORDER_DESC], $cursorExecution ?? null, $cursorDirection);
$sum = $dbForProject->count('executions', $queries, APP_LIMIT_COUNT);
$total = $dbForProject->count('executions', $queries, APP_LIMIT_COUNT);
$response->dynamic(new Document([
'executions' => $results,
'sum' => $sum,
'total' => $total,
]), Response::MODEL_EXECUTION_LIST);
});

View file

@ -100,7 +100,7 @@ App::get('/v1/locale/countries')
return strcmp($a->getAttribute('name'), $b->getAttribute('name'));
});
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
$response->dynamic(new Document(['countries' => $output, 'total' => \count($output)]), Response::MODEL_COUNTRY_LIST);
});
App::get('/v1/locale/countries/eu')
@ -136,7 +136,7 @@ App::get('/v1/locale/countries/eu')
return strcmp($a->getAttribute('name'), $b->getAttribute('name'));
});
$response->dynamic(new Document(['countries' => $output, 'sum' => \count($output)]), Response::MODEL_COUNTRY_LIST);
$response->dynamic(new Document(['countries' => $output, 'total' => \count($output)]), Response::MODEL_COUNTRY_LIST);
});
App::get('/v1/locale/countries/phones')
@ -171,7 +171,7 @@ App::get('/v1/locale/countries/phones')
}
}
$response->dynamic(new Document(['phones' => $output, 'sum' => \count($output)]), Response::MODEL_PHONE_LIST);
$response->dynamic(new Document(['phones' => $output, 'total' => \count($output)]), Response::MODEL_PHONE_LIST);
});
App::get('/v1/locale/continents')
@ -204,7 +204,7 @@ App::get('/v1/locale/continents')
return strcmp($a->getAttribute('name'), $b->getAttribute('name'));
});
$response->dynamic(new Document(['continents' => $output, 'sum' => \count($output)]), Response::MODEL_CONTINENT_LIST);
$response->dynamic(new Document(['continents' => $output, 'total' => \count($output)]), Response::MODEL_CONTINENT_LIST);
});
App::get('/v1/locale/currencies')
@ -226,7 +226,7 @@ App::get('/v1/locale/currencies')
$list = array_map(fn($node) => new Document($node), $list);
$response->dynamic(new Document(['currencies' => $list, 'sum' => \count($list)]), Response::MODEL_CURRENCY_LIST);
$response->dynamic(new Document(['currencies' => $list, 'total' => \count($list)]), Response::MODEL_CURRENCY_LIST);
});
@ -249,5 +249,5 @@ App::get('/v1/locale/languages')
$list = array_map(fn ($node) => new Document($node), $list);
$response->dynamic(new Document(['languages' => $list, 'sum' => \count($list)]), Response::MODEL_LANGUAGE_LIST);
$response->dynamic(new Document(['languages' => $list, 'total' => \count($list)]), Response::MODEL_LANGUAGE_LIST);
});

View file

@ -186,11 +186,11 @@ App::get('/v1/projects')
}
$results = $dbForConsole->find('projects', $queries, $limit, $offset, [], [$orderType], $cursorProject ?? null, $cursorDirection);
$sum = $dbForConsole->count('projects', $queries, APP_LIMIT_COUNT);
$total = $dbForConsole->count('projects', $queries, APP_LIMIT_COUNT);
$response->dynamic(new Document([
'projects' => $results,
'sum' => $sum,
'total' => $total,
]), Response::MODEL_PROJECT_LIST);
});
@ -649,11 +649,11 @@ App::get('/v1/projects/:projectId/webhooks')
$webhooks = $dbForConsole->find('webhooks', [
new Query('projectId', Query::TYPE_EQUAL, [$project->getId()])
]);
], 5000);
$response->dynamic(new Document([
'webhooks' => $webhooks,
'sum' => count($webhooks),
'total' => count($webhooks),
]), Response::MODEL_WEBHOOK_LIST);
});
@ -863,7 +863,7 @@ App::get('/v1/projects/:projectId/keys')
$response->dynamic(new Document([
'keys' => $keys,
'sum' => count($keys),
'total' => count($keys),
]), Response::MODEL_KEY_LIST);
});
@ -1070,7 +1070,7 @@ App::get('/v1/projects/:projectId/platforms')
$response->dynamic(new Document([
'platforms' => $platforms,
'sum' => count($platforms),
'total' => count($platforms),
]), Response::MODEL_PLATFORM_LIST);
});
@ -1294,7 +1294,7 @@ App::get('/v1/projects/:projectId/domains')
$response->dynamic(new Document([
'domains' => $domains,
'sum' => count($domains),
'total' => count($domains),
]), Response::MODEL_DOMAIN_LIST);
});

View file

@ -174,7 +174,7 @@ App::get('/v1/storage/buckets')
$response->dynamic(new Document([
'buckets' => $dbForProject->find('buckets', $queries, $limit, $offset, [], [$orderType], $cursorBucket ?? null, $cursorDirection),
'sum' => $dbForProject->count('buckets', $queries, APP_LIMIT_COUNT),
'total' => $dbForProject->count('buckets', $queries, APP_LIMIT_COUNT),
]), Response::MODEL_BUCKET_LIST);
});
@ -771,7 +771,7 @@ App::get('/v1/storage/buckets/:bucketId/files')
$response->dynamic(new Document([
'files' => $files,
'sum' => $dbForProject->count('bucket_' . $bucket->getInternalId(), $queries, APP_LIMIT_COUNT),
'total' => $dbForProject->count('bucket_' . $bucket->getInternalId(), $queries, APP_LIMIT_COUNT),
]), Response::MODEL_FILE_LIST);
});

View file

@ -57,7 +57,7 @@ App::post('/v1/teams')
'$read' => ['team:'.$teamId],
'$write' => ['team:'.$teamId .'/owner'],
'name' => $name,
'sum' => ($isPrivilegedUser || $isAppUser) ? 0 : 1,
'total' => ($isPrivilegedUser || $isAppUser) ? 0 : 1,
'dateCreated' => \time(),
'search' => implode(' ', [$teamId, $name]),
])));
@ -131,11 +131,11 @@ App::get('/v1/teams')
}
$results = $dbForProject->find('teams', $queries, $limit, $offset, [], [$orderType], $cursorTeam ?? null, $cursorDirection);
$sum = $dbForProject->count('teams', $queries, APP_LIMIT_COUNT);
$total = $dbForProject->count('teams', $queries, APP_LIMIT_COUNT);
$response->dynamic(new Document([
'teams' => $results,
'sum' => $sum,
'total' => $total,
]), Response::MODEL_TEAM_LIST);
});
@ -311,9 +311,9 @@ App::post('/v1/teams/:teamId/memberships')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0 && $project->getId() !== 'console') { // check users limit, console invites are allways allowed.
$sum = $dbForProject->count('users', [], APP_LIMIT_USERS);
$total = $dbForProject->count('users', [], APP_LIMIT_USERS);
if($sum >= $limit) {
if($total >= $limit) {
throw new Exception('Project registration is restricted. Contact your administrator for more information.', 501, Exception::USER_COUNT_EXCEEDED);
}
}
@ -377,7 +377,7 @@ App::post('/v1/teams/:teamId/memberships')
} catch (Duplicate $th) {
throw new Exception('User has already been invited or is already a member of this team', 409, Exception::TEAM_INVITE_ALREADY_EXISTS);
}
$team->setAttribute('sum', $team->getAttribute('sum', 0) + 1);
$team->setAttribute('total', $team->getAttribute('total', 0) + 1);
$team = Authorization::skip(fn() => $dbForProject->updateDocument('teams', $team->getId(), $team));
// Attach user to team
@ -479,7 +479,7 @@ App::get('/v1/teams/:teamId/memberships')
cursorDirection: $cursorDirection
);
$sum = $dbForProject->count(
$total = $dbForProject->count(
collection:'memberships',
queries: $queries,
max: APP_LIMIT_COUNT
@ -500,7 +500,7 @@ App::get('/v1/teams/:teamId/memberships')
$response->dynamic(new Document([
'memberships' => $memberships,
'sum' => $sum,
'total' => $total,
]), Response::MODEL_MEMBERSHIP_LIST);
});
@ -731,7 +731,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
$membership = $dbForProject->updateDocument('memberships', $membership->getId(), $membership);
$team = Authorization::skip(fn() => $dbForProject->updateDocument('teams', $team->getId(), $team->setAttribute('sum', $team->getAttribute('sum', 0) + 1)));
$team = Authorization::skip(fn() => $dbForProject->updateDocument('teams', $team->getId(), $team->setAttribute('total', $team->getAttribute('total', 0) + 1)));
$audits
->setParam('userId', $user->getId())
@ -825,7 +825,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId')
Authorization::skip(fn() => $dbForProject->updateDocument('users', $user->getId(), $user));
if ($membership->getAttribute('confirm')) { // Count only confirmed members
$team->setAttribute('sum', \max($team->getAttribute('sum', 0) - 1, 0));
$team->setAttribute('total', \max($team->getAttribute('total', 0) - 1, 0));
Authorization::skip(fn() => $dbForProject->updateDocument('teams', $team->getId(), $team));
}

View file

@ -128,7 +128,7 @@ App::get('/v1/users')
$response->dynamic(new Document([
'users' => $dbForProject->find('users', $queries, $limit, $offset, [], [$orderType], $cursorUser ?? null, $cursorDirection),
'sum' => $dbForProject->count('users', $queries, APP_LIMIT_COUNT),
'total' => $dbForProject->count('users', $queries, APP_LIMIT_COUNT),
]), Response::MODEL_USER_LIST);
});
@ -243,7 +243,7 @@ App::get('/v1/users/:userId/sessions')
;
$response->dynamic(new Document([
'sessions' => $sessions,
'sum' => count($sessions),
'total' => count($sessions),
]), Response::MODEL_SESSION_LIST);
});
@ -348,7 +348,7 @@ App::get('/v1/users/:userId/logs')
;
$response->dynamic(new Document([
'sum' => $audit->countLogsByUserAndEvents($user->getId(), $auditEvents),
'total' => $audit->countLogsByUserAndEvents($user->getId(), $auditEvents),
'logs' => $output,
]), Response::MODEL_LOG_LIST);
});

View file

@ -487,7 +487,7 @@ $cli
'files' => [
'namespace' => '',
'collectionPrefix' => 'bucket_',
'sum' => [
'total' => [
'field' => 'sizeOriginal'
]
],
@ -613,13 +613,13 @@ $cli
}
// check if sum calculation is required
$sum = $subOptions['sum'] ?? [];
if(empty($sum)) {
$total = $subOptions['total'] ?? [];
if(empty($total)) {
continue;
}
$dbForProject->setNamespace("_project_{$projectId}");
$total = (int) $dbForProject->sum(($subOptions['collectionPrefix'] ?? '') . $parent->getId(), $sum['field']);
$total = (int) $dbForProject->sum(($subOptions['collectionPrefix'] ?? '') . $parent->getId(), $total['field']);
$subCollectionTotals[$subCollection] = ($ssubCollectionTotals[$subCollection] ?? 0) + $total; // Project level sum for sub collections like storage.total

View file

@ -227,7 +227,7 @@ class DeletesV1 extends Worker
$team = $this->getProjectDB($projectId)->getDocument('teams', $teamId);
if (!$team->isEmpty()) {
$team = $this->getProjectDB($projectId)->updateDocument('teams', $teamId, new Document(\array_merge($team->getArrayCopy(), [
'sum' => \max($team->getAttribute('sum', 0) - 1, 0), // Ensure that sum >= 0
'total' => \max($team->getAttribute('total', 0) - 1, 0), // Ensure that sum >= 0
])));
}
}

View file

@ -157,7 +157,7 @@ class Response extends SwooleResponse
const MODEL_EXECUTION = 'execution';
const MODEL_EXECUTION_LIST = 'executionList';
const MODEL_BUILD = 'build';
const MODEL_BUILD_LIST = 'buildList';
const MODEL_BUILD_LIST = 'buildList'; // Not used anywhere yet
const MODEL_FUNC_PERMISSIONS = 'funcPermissions';
// Project
@ -225,7 +225,7 @@ class Response extends SwooleResponse
->setModel(new BaseList('Runtimes List', self::MODEL_RUNTIME_LIST, 'runtimes', self::MODEL_RUNTIME))
->setModel(new BaseList('Deployments List', self::MODEL_DEPLOYMENT_LIST, 'deployments', self::MODEL_DEPLOYMENT))
->setModel(new BaseList('Executions List', self::MODEL_EXECUTION_LIST, 'executions', self::MODEL_EXECUTION))
->setModel(new BaseList('Builds List', self::MODEL_BUILD_LIST, 'builds', self::MODEL_BUILD))
->setModel(new BaseList('Builds List', self::MODEL_BUILD_LIST, 'builds', self::MODEL_BUILD)) // Not used anywhere yet
->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false))
->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false))
->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false))

View file

@ -11,9 +11,9 @@ class AttributeList extends Model
public function __construct()
{
$this
->addRule('sum', [
->addRule('total', [
'type' => self::TYPE_INTEGER,
'description' => 'Total sum of items in the list.',
'description' => 'Total amount of attributes in a collection.',
'default' => 0,
'example' => 5,
])

View file

@ -32,9 +32,21 @@ class BaseList extends Model
$this->public = $public;
if ($paging) {
$this->addRule('sum', [
$namesWithCap = [
'documents', 'collections', 'users', 'files', 'buckets', 'functions',
'deployments', 'executions', 'projects', 'webhooks', 'keys',
'platforms', 'domains', 'memberships', 'teams'
];
if (\in_array($namesWithCap, $name)) {
$description = 'Total number of ' . $key . ' documents that matched your query used as reference for offset pagination. When the `total` is more than 5000, it will be capped at 5000, and cursor pagination should be used. Read more about [pagination](https://appwrite.io/docs/pagination).';
} else {
$description = 'Total number of ' . $key . ' documents that matched your query.';
}
$this->addRule('total', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of items available on the server.',
'description' => $description,
'default' => 0,
'example' => 5,
]);

View file

@ -28,9 +28,9 @@ class Team extends Model
'default' => 0,
'example' => 1592981250,
])
->addRule('sum', [
->addRule('total', [
'type' => self::TYPE_INTEGER,
'description' => 'Total sum of team members.',
'description' => 'Total number of team members.',
'default' => 0,
'example' => 7,
])

View file

@ -267,7 +267,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertCount(2, $response['body']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
$this->assertEquals($sessionId, $response['body']['sessions'][0]['$id']);
$this->assertEquals('Windows', $response['body']['sessions'][0]['osName']);
@ -325,7 +325,7 @@ trait AccountBase
$this->assertIsArray($response['body']['logs']);
$this->assertNotEmpty($response['body']['logs']);
$this->assertCount(2, $response['body']['logs']);
$this->assertIsNumeric($response['body']['sum']);
$this->assertIsNumeric($response['body']['total']);
$this->assertContains($response['body']['logs'][0]['event'], ['account.create', 'account.sessions.create']);
$this->assertEquals($response['body']['logs'][0]['ip'], filter_var($response['body']['logs'][0]['ip'], FILTER_VALIDATE_IP));
@ -384,7 +384,7 @@ trait AccountBase
$this->assertIsArray($responseLimit['body']['logs']);
$this->assertNotEmpty($responseLimit['body']['logs']);
$this->assertCount(1, $responseLimit['body']['logs']);
$this->assertIsNumeric($responseLimit['body']['sum']);
$this->assertIsNumeric($responseLimit['body']['total']);
$this->assertEquals($response['body']['logs'][0], $responseLimit['body']['logs'][0]);
@ -401,7 +401,7 @@ trait AccountBase
$this->assertIsArray($responseOffset['body']['logs']);
$this->assertNotEmpty($responseOffset['body']['logs']);
$this->assertCount(1, $responseOffset['body']['logs']);
$this->assertIsNumeric($responseOffset['body']['sum']);
$this->assertIsNumeric($responseOffset['body']['total']);
$this->assertEquals($response['body']['logs'][1], $responseOffset['body']['logs'][0]);
@ -419,7 +419,7 @@ trait AccountBase
$this->assertIsArray($responseLimitOffset['body']['logs']);
$this->assertNotEmpty($responseLimitOffset['body']['logs']);
$this->assertCount(1, $responseLimitOffset['body']['logs']);
$this->assertIsNumeric($responseLimitOffset['body']['sum']);
$this->assertIsNumeric($responseLimitOffset['body']['total']);
$this->assertEquals($response['body']['logs'][1], $responseLimitOffset['body']['logs'][0]);
/**

View file

@ -472,7 +472,7 @@ trait DatabaseBase
]));
$this->assertEquals(200, $attributes['headers']['status-code']);
$this->assertEquals(8, $attributes['body']['sum']);
$this->assertEquals(8, $attributes['body']['total']);
$attributes = $attributes['body']['attributes'];
@ -2017,7 +2017,7 @@ trait DatabaseBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(3, $documents['body']['sum']);
$this->assertEquals(3, $documents['body']['total']);
$this->assertCount(3, $documents['body']['documents']);
/*

View file

@ -138,7 +138,7 @@ class DatabaseConsoleClientTest extends Scope
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -150,7 +150,7 @@ class DatabaseConsoleClientTest extends Scope
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -161,7 +161,7 @@ class DatabaseConsoleClientTest extends Scope
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -174,6 +174,6 @@ class DatabaseConsoleClientTest extends Scope
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
}
}

View file

@ -48,7 +48,7 @@ class DatabaseCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(2, $collections['body']['sum']);
$this->assertEquals(2, $collections['body']['total']);
$this->assertEquals($test1['body']['$id'], $collections['body']['collections'][0]['$id']);
$this->assertEquals($test2['body']['$id'], $collections['body']['collections'][1]['$id']);
@ -63,7 +63,7 @@ class DatabaseCustomServerTest extends Scope
'orderType' => 'DESC'
]);
$this->assertEquals(2, $collections['body']['sum']);
$this->assertEquals(2, $collections['body']['total']);
$this->assertEquals($base[0]['$id'], $collections['body']['collections'][0]['$id']);
$this->assertEquals($base[1]['$id'], $collections['body']['collections'][1]['$id']);
@ -135,7 +135,7 @@ class DatabaseCustomServerTest extends Scope
'search' => 'first'
]);
$this->assertEquals(1, $collections['body']['sum']);
$this->assertEquals(1, $collections['body']['total']);
$this->assertEquals('first', $collections['body']['collections'][0]['$id']);
$collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
@ -145,7 +145,7 @@ class DatabaseCustomServerTest extends Scope
'search' => 'Test'
]);
$this->assertEquals(2, $collections['body']['sum']);
$this->assertEquals(2, $collections['body']['total']);
$this->assertEquals('Test 1', $collections['body']['collections'][0]['name']);
$this->assertEquals('Test 2', $collections['body']['collections'][1]['name']);
@ -156,7 +156,7 @@ class DatabaseCustomServerTest extends Scope
'search' => 'Nonexistent'
]);
$this->assertEquals(0, $collections['body']['sum']);
$this->assertEquals(0, $collections['body']['total']);
/**
* Test for FAILURE

View file

@ -32,8 +32,8 @@ trait FunctionsBase
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']);
// $this->assertEquals('Arsenal', $response['body']['name']);
// $this->assertGreaterThan(-1, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(-1, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertIsInt($response['body']['dateCreated']);
// /**
@ -57,8 +57,8 @@ trait FunctionsBase
// ], $this->getHeaders()));
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertGreaterThan(0, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(0, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertCount(3, $response['body']['teams']);
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -69,8 +69,8 @@ trait FunctionsBase
// ]);
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertGreaterThan(0, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(0, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertCount(2, $response['body']['teams']);
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -81,8 +81,8 @@ trait FunctionsBase
// ]);
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertGreaterThan(0, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(0, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertCount(2, $response['body']['teams']);
// $response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -93,8 +93,8 @@ trait FunctionsBase
// ]);
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertGreaterThan(0, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(0, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertCount(1, $response['body']['teams']);
// $this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
@ -106,8 +106,8 @@ trait FunctionsBase
// ]);
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertGreaterThan(0, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(0, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertCount(1, $response['body']['teams']);
// $this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
@ -133,8 +133,8 @@ trait FunctionsBase
// $this->assertEquals(201, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']);
// $this->assertEquals('Demo', $response['body']['name']);
// $this->assertGreaterThan(-1, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(-1, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertIsInt($response['body']['dateCreated']);
// $response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
@ -147,8 +147,8 @@ trait FunctionsBase
// $this->assertEquals(200, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']);
// $this->assertEquals('Demo New', $response['body']['name']);
// $this->assertGreaterThan(-1, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(-1, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertIsInt($response['body']['dateCreated']);
// /**
@ -182,8 +182,8 @@ trait FunctionsBase
// $this->assertEquals(201, $response['headers']['status-code']);
// $this->assertNotEmpty($response['body']['$id']);
// $this->assertEquals('Demo', $response['body']['name']);
// $this->assertGreaterThan(-1, $response['body']['sum']);
// $this->assertIsInt($response['body']['sum']);
// $this->assertGreaterThan(-1, $response['body']['total']);
// $this->assertIsInt($response['body']['total']);
// $this->assertIsInt($response['body']['dateCreated']);
// $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid, array_merge([

View file

@ -146,7 +146,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals($functions['body']['sum'], 2);
$this->assertEquals($functions['body']['total'], 2);
$this->assertIsArray($functions['body']['functions']);
$this->assertCount(2, $functions['body']['functions']);
$this->assertEquals($functions['body']['functions'][0]['name'], 'Test');
@ -389,7 +389,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals($function['body']['sum'], 2);
$this->assertEquals($function['body']['total'], 2);
$this->assertIsArray($function['body']['deployments']);
$this->assertCount(2, $function['body']['deployments']);
@ -404,7 +404,7 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals(2, $function['body']['sum']);
$this->assertEquals(2, $function['body']['total']);
$this->assertIsArray($function['body']['deployments']);
$this->assertCount(2, $function['body']['deployments']);
$this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']);
@ -417,7 +417,7 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals(2, $function['body']['sum']);
$this->assertEquals(2, $function['body']['total']);
$this->assertIsArray($function['body']['deployments']);
$this->assertCount(2, $function['body']['deployments']);
$this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']);
@ -430,7 +430,7 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals(2, $function['body']['sum']);
$this->assertEquals(2, $function['body']['total']);
$this->assertIsArray($function['body']['deployments']);
$this->assertCount(2, $function['body']['deployments']);
$this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']);
@ -540,7 +540,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals($function['body']['sum'], 1);
$this->assertEquals($function['body']['total'], 1);
$this->assertIsArray($function['body']['executions']);
$this->assertCount(1, $function['body']['executions']);
$this->assertEquals($function['body']['executions'][0]['$id'], $data['executionId']);
@ -557,8 +557,8 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['executions']);
$this->assertEquals($data['functionId'], $response['body']['executions'][0]['functionId']);
@ -570,8 +570,8 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['executions']);
$this->assertEquals($data['executionId'], $response['body']['executions'][0]['$id']);
@ -753,7 +753,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -868,7 +868,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -974,7 +974,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -1079,7 +1079,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -1184,7 +1184,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -1289,7 +1289,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['sum'], 1);
$this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -1394,7 +1394,7 @@ class FunctionsCustomServerTest extends Scope
// ], $this->getHeaders()));
// $this->assertEquals($executions['headers']['status-code'], 200);
// $this->assertEquals($executions['body']['sum'], 1);
// $this->assertEquals($executions['body']['total'], 1);
// $this->assertIsArray($executions['body']['executions']);
// $this->assertCount(1, $executions['body']['executions']);
// $this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
@ -1419,7 +1419,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals(200, $runtimes['headers']['status-code']);
$this->assertGreaterThan(0, $runtimes['body']['sum']);
$this->assertGreaterThan(0, $runtimes['body']['total']);
$runtime = $runtimes['body']['runtimes'][0];

View file

@ -45,7 +45,7 @@ trait LocaleBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertEquals(194, $response['body']['sum']);
$this->assertEquals(194, $response['body']['total']);
$this->assertEquals($response['body']['countries'][0]['name'], 'Afghanistan');
$this->assertEquals($response['body']['countries'][0]['code'], 'AF');
@ -59,7 +59,7 @@ trait LocaleBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertEquals(194, $response['body']['sum']);
$this->assertEquals(194, $response['body']['total']);
$this->assertEquals($response['body']['countries'][0]['name'], 'Afganistán');
$this->assertEquals($response['body']['countries'][0]['code'], 'AF');
@ -81,7 +81,7 @@ trait LocaleBase
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(27, $response['body']['sum']);
$this->assertEquals(27, $response['body']['total']);
$this->assertIsArray($response['body']['countries']);
$this->assertEquals($response['body']['countries'][0]['name'], 'Austria');
$this->assertEquals($response['body']['countries'][0]['code'], 'AT');
@ -95,7 +95,7 @@ trait LocaleBase
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(27, $response['body']['sum']);
$this->assertEquals(27, $response['body']['total']);
$this->assertIsArray($response['body']['countries']);
$this->assertEquals($response['body']['countries'][0]['name'], 'Alemania');
$this->assertEquals($response['body']['countries'][0]['code'], 'DE');
@ -120,7 +120,7 @@ trait LocaleBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertEquals(194, $response['body']['sum']);
$this->assertEquals(194, $response['body']['total']);
$this->assertIsArray($response['body']['phones']);
$this->assertEquals($response['body']['phones'][0]['code'], '+1');
$this->assertEquals($response['body']['phones'][0]['countryName'], 'Canada');
@ -144,7 +144,7 @@ trait LocaleBase
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(7, $response['body']['sum']);
$this->assertEquals(7, $response['body']['total']);
$this->assertIsArray($response['body']['continents']);
$this->assertEquals($response['body']['continents'][0]['code'], 'AF');
$this->assertEquals($response['body']['continents'][0]['name'], 'Africa');
@ -157,7 +157,7 @@ trait LocaleBase
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(7, $response['body']['sum']);
$this->assertEquals(7, $response['body']['total']);
$this->assertIsArray($response['body']['continents']);
$this->assertEquals($response['body']['continents'][0]['code'], 'NA');
$this->assertEquals($response['body']['continents'][0]['name'], 'América del Norte');
@ -182,7 +182,7 @@ trait LocaleBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertEquals(117, $response['body']['sum']);
$this->assertEquals(117, $response['body']['total']);
$this->assertEquals($response['body']['currencies'][0]['symbol'], '$');
$this->assertEquals($response['body']['currencies'][0]['name'], 'US Dollar');
@ -205,7 +205,7 @@ trait LocaleBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertEquals(184, $response['body']['sum']);
$this->assertEquals(184, $response['body']['total']);
$this->assertEquals($response['body']['languages'][0]['code'], 'aa');
$this->assertEquals($response['body']['languages'][0]['name'], 'Afar');
@ -251,7 +251,7 @@ trait LocaleBase
// }
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(194, $response['body']['sum']);
$this->assertEquals(194, $response['body']['total']);
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
@ -268,7 +268,7 @@ trait LocaleBase
// }
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(7, $response['body']['sum']);
$this->assertEquals(7, $response['body']['total']);
}
/**

View file

@ -110,7 +110,7 @@ class ProjectsConsoleClientTest extends Scope
]));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals($response['body']['sum'], 1);
$this->assertEquals($response['body']['total'], 1);
$this->assertIsArray($response['body']['projects']);
$this->assertCount(1, $response['body']['projects']);
$this->assertEquals($response['body']['projects'][0]['name'], 'Project Test');
@ -123,7 +123,7 @@ class ProjectsConsoleClientTest extends Scope
]));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals($response['body']['sum'], 1);
$this->assertEquals($response['body']['total'], 1);
$this->assertIsArray($response['body']['projects']);
$this->assertCount(1, $response['body']['projects']);
$this->assertEquals($response['body']['projects'][0]['$id'], $data['projectId']);
@ -861,7 +861,7 @@ class ProjectsConsoleClientTest extends Scope
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
/**
* Test for FAILURE
@ -1095,7 +1095,7 @@ class ProjectsConsoleClientTest extends Scope
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
/**
* Test for FAILURE
@ -1420,7 +1420,7 @@ class ProjectsConsoleClientTest extends Scope
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(7, $response['body']['sum']);
$this->assertEquals(7, $response['body']['total']);
/**
* Test for FAILURE
@ -1926,7 +1926,7 @@ class ProjectsConsoleClientTest extends Scope
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
/**
* Test for FAILURE

View file

@ -203,7 +203,7 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $files['headers']['status-code']);
$this->assertGreaterThan(0, $files['body']['sum']);
$this->assertGreaterThan(0, $files['body']['total']);
$this->assertGreaterThan(0, count($files['body']['files']));
/**

View file

@ -23,8 +23,8 @@ trait TeamsBase
$this->assertEquals(201, $response1['headers']['status-code']);
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Arsenal', $response1['body']['name']);
$this->assertGreaterThan(-1, $response1['body']['sum']);
$this->assertIsInt($response1['body']['sum']);
$this->assertGreaterThan(-1, $response1['body']['total']);
$this->assertIsInt($response1['body']['total']);
$this->assertIsInt($response1['body']['dateCreated']);
$teamUid = $response1['body']['$id'];
@ -43,8 +43,8 @@ trait TeamsBase
$this->assertNotEmpty($response2['body']['$id']);
$this->assertEquals($teamId, $response2['body']['$id']);
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['sum']);
$this->assertIsInt($response2['body']['sum']);
$this->assertGreaterThan(-1, $response2['body']['total']);
$this->assertIsInt($response2['body']['total']);
$this->assertIsInt($response2['body']['dateCreated']);
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
@ -58,8 +58,8 @@ trait TeamsBase
$this->assertEquals(201, $response3['headers']['status-code']);
$this->assertNotEmpty($response3['body']['$id']);
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['sum']);
$this->assertIsInt($response3['body']['sum']);
$this->assertGreaterThan(-1, $response3['body']['total']);
$this->assertIsInt($response3['body']['total']);
$this->assertIsInt($response3['body']['dateCreated']);
/**
@ -94,8 +94,8 @@ trait TeamsBase
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
/**
@ -119,8 +119,8 @@ trait TeamsBase
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertGreaterThan(2, count($response['body']['teams']));
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -131,8 +131,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(2, $response['body']['teams']);
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -143,8 +143,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertGreaterThan(2, $response['body']['teams']);
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -155,8 +155,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['teams']);
$this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
@ -168,8 +168,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['teams']);
$this->assertEquals('Manchester United', $response['body']['teams'][0]['name']);
@ -181,8 +181,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['teams']);
$this->assertEquals('Arsenal', $response['body']['teams'][0]['name']);
@ -194,8 +194,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $teams['headers']['status-code']);
$this->assertGreaterThan(0, $teams['body']['sum']);
$this->assertIsInt($teams['body']['sum']);
$this->assertGreaterThan(0, $teams['body']['total']);
$this->assertIsInt($teams['body']['total']);
$this->assertCount(2, $teams['body']['teams']);
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
@ -207,8 +207,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['teams']);
$this->assertEquals($teams['body']['teams'][1]['$id'], $response['body']['teams'][0]['$id']);
@ -222,8 +222,8 @@ trait TeamsBase
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertGreaterThan(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertCount(1, $response['body']['teams']);
$this->assertEquals($teams['body']['teams'][0]['$id'], $response['body']['teams'][0]['$id']);
@ -258,8 +258,8 @@ trait TeamsBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
$response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
@ -273,8 +273,8 @@ trait TeamsBase
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
/**
@ -309,8 +309,8 @@ trait TeamsBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
$response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid, array_merge([

View file

@ -22,7 +22,7 @@ trait TeamsBaseClient
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertNotEmpty($response['body']['memberships'][0]['$id']);
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['name']);
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['email']);
@ -38,7 +38,7 @@ trait TeamsBaseClient
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertNotEmpty($response['body']['memberships'][0]);
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['name']);
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['email']);
@ -52,7 +52,7 @@ trait TeamsBaseClient
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertNotEmpty($response['body']['memberships'][0]);
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['name']);
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['email']);
@ -66,9 +66,9 @@ trait TeamsBaseClient
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertEmpty($response['body']['memberships']);
$this->assertEquals(0, $response['body']['sum']);
$this->assertEquals(0, $response['body']['total']);
/**
* Test for FAILURE
@ -191,7 +191,7 @@ trait TeamsBaseClient
], $this->getHeaders()));
$this->assertEquals(200, $memberships['headers']['status-code']);
$this->assertIsInt($memberships['body']['sum']);
$this->assertIsInt($memberships['body']['total']);
$this->assertNotEmpty($memberships['body']['memberships']);
$this->assertCount(2, $memberships['body']['memberships']);
@ -203,7 +203,7 @@ trait TeamsBaseClient
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertNotEmpty($response['body']['memberships']);
$this->assertCount(1, $response['body']['memberships']);
$this->assertEquals($memberships['body']['memberships'][1]['$id'], $response['body']['memberships'][0]['$id']);
@ -441,7 +441,7 @@ trait TeamsBaseClient
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(2, $response['body']['sum']);
$this->assertEquals(2, $response['body']['total']);
$ownerMembershipUid = $response['body']['memberships'][0]['$id'];
@ -496,7 +496,7 @@ trait TeamsBaseClient
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
/**
* Test for when the owner tries to delete their membership

View file

@ -22,7 +22,7 @@ trait TeamsBaseServer
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(0, $response['body']['sum']);
$this->assertEquals(0, $response['body']['total']);
/**
* Test for FAILURE
@ -201,8 +201,8 @@ trait TeamsBaseServer
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
@ -227,8 +227,8 @@ trait TeamsBaseServer
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(0, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertEquals(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['dateCreated']);
}

View file

@ -155,8 +155,8 @@ trait UsersBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertIsArray($response['body']['users']);
$this->assertIsInt($response['body']['sum']);
$this->assertEquals(1, $response['body']['sum']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(1, $response['body']['total']);
$this->assertCount(1, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
@ -219,8 +219,8 @@ trait UsersBase
$this->assertEquals($users['headers']['status-code'], 200);
$this->assertIsArray($users['body']);
$this->assertIsArray($users['body']['users']);
$this->assertIsInt($users['body']['sum']);
$this->assertGreaterThan(0, $users['body']['sum']);
$this->assertIsInt($users['body']['total']);
$this->assertGreaterThan(0, $users['body']['total']);
return $data;
}
@ -443,7 +443,7 @@ trait UsersBase
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -455,7 +455,7 @@ trait UsersBase
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -466,7 +466,7 @@ trait UsersBase
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
@ -479,7 +479,7 @@ trait UsersBase
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['sum']);
$this->assertIsNumeric($logs['body']['total']);
}
/**

View file

@ -544,8 +544,8 @@ trait WebhooksBase
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals('Arsenal', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['sum']);
$this->assertIsInt($webhook['data']['sum']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['dateCreated']);
/**
@ -584,8 +584,8 @@ trait WebhooksBase
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals('Demo New', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['sum']);
$this->assertIsInt($webhook['data']['sum']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['dateCreated']);
/**
@ -627,8 +627,8 @@ trait WebhooksBase
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals('Chelsea', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['sum']);
$this->assertIsInt($webhook['data']['sum']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['dateCreated']);
/**

View file

@ -310,7 +310,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']);
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']);
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertEquals($webhook['data']['sum'], 2);
$this->assertEquals($webhook['data']['total'], 2);
$this->assertNotEmpty($webhook['data']['sessions'][1]['$id']);
$this->assertNotEmpty($webhook['data']['sessions'][1]['userId']);
$this->assertIsInt($webhook['data']['sessions'][1]['expire']);