1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00
appwrite/tests/e2e/Services/Users/UsersBase.php

619 lines
23 KiB
PHP
Raw Normal View History

2020-01-14 07:30:13 +13:00
<?php
namespace Tests\E2E\Services\Users;
use Tests\E2E\Client;
use Utopia\Database\Database;
2020-01-14 07:30:13 +13:00
trait UsersBase
{
2022-05-24 02:54:50 +12:00
public function testCreateUser(): array
2020-01-14 07:30:13 +13:00
{
/**
* Test for SUCCESS
*/
2020-01-14 07:55:57 +13:00
$user = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
2021-07-06 18:23:33 +12:00
'userId' => 'unique()',
2021-10-06 10:15:43 +13:00
'email' => 'cristiano.ronaldo@manchester-united.co.uk',
2020-01-14 07:55:57 +13:00
'password' => 'password',
2021-10-06 10:15:43 +13:00
'name' => 'Cristiano Ronaldo',
2021-12-30 21:09:23 +13:00
], false);
// Test empty prefs is object not array
$bodyString = $user['body'];
2022-05-24 02:54:50 +12:00
$prefs = substr($bodyString, strpos($bodyString, '"prefs":') + 8, 2);
2021-12-30 21:09:23 +13:00
$this->assertEquals('{}', $prefs);
2022-05-13 01:20:06 +12:00
2021-12-30 21:09:23 +13:00
$body = json_decode($bodyString, true);
2020-01-14 07:55:57 +13:00
$this->assertEquals($user['headers']['status-code'], 201);
2021-12-30 21:09:23 +13:00
$this->assertEquals($body['name'], 'Cristiano Ronaldo');
$this->assertEquals($body['email'], 'cristiano.ronaldo@manchester-united.co.uk');
$this->assertEquals($body['status'], true);
$this->assertGreaterThan(0, $body['registration']);
2020-01-14 07:55:57 +13:00
2021-07-05 23:03:52 +12:00
/**
* Test Create with Custom ID for SUCCESS
*/
$res = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2021-07-06 18:23:33 +12:00
'userId' => 'user1',
2021-10-06 10:15:43 +13:00
'email' => 'lionel.messi@psg.fr',
2021-07-05 23:03:52 +12:00
'password' => 'password',
2021-10-06 10:15:43 +13:00
'name' => 'Lionel Messi',
2021-07-05 23:03:52 +12:00
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['$id'], 'user1');
2021-10-06 10:15:43 +13:00
$this->assertEquals($res['body']['name'], 'Lionel Messi');
$this->assertEquals($res['body']['email'], 'lionel.messi@psg.fr');
2021-07-30 00:14:40 +12:00
$this->assertEquals(true, $res['body']['status']);
2021-07-05 23:03:52 +12:00
$this->assertGreaterThan(0, $res['body']['registration']);
2021-12-30 21:09:23 +13:00
return ['userId' => $body['$id']];
2020-01-14 07:55:57 +13:00
}
2021-08-10 00:55:30 +12:00
/**
* @depends testCreateUser
*/
public function testListUsers(array $data): void
{
/**
2021-09-21 20:22:13 +12:00
* Test for SUCCESS listUsers
2021-08-10 00:55:30 +12:00
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(2, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$this->assertEquals($response['body']['users'][1]['$id'], 'user1');
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'cursor' => $response['body']['users'][0]['$id']
2021-08-10 00:55:30 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], 'user1');
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'cursor' => 'user1',
'cursorDirection' => Database::CURSOR_BEFORE
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
/**
2021-09-21 20:22:13 +12:00
* Test for SUCCESS searchUsers
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2021-10-06 10:15:43 +13:00
'search' => 'Ronaldo'
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2022-03-16 01:04:24 +13:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'cristiano.ronaldo@manchester-united.co.uk'
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2021-09-21 20:22:13 +12:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2021-10-06 10:15:43 +13:00
'search' => 'cristiano.ronaldo'
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2021-10-06 10:15:43 +13:00
'search' => 'manchester'
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-02-22 22:39:33 +13:00
'search' => 'united.co.uk'
2022-02-22 10:53:23 +13:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertIsArray($response['body']['users']);
2022-03-02 00:09:34 +13:00
$this->assertIsInt($response['body']['total']);
$this->assertEquals(1, $response['body']['total']);
2022-02-22 10:53:23 +13:00
$this->assertCount(1, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-02-22 22:39:33 +13:00
'search' => 'man'
]);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['headers']['status-code'], 200);
2021-10-06 10:15:43 +13:00
$this->assertIsArray($response['body']);
$this->assertIsArray($response['body']['users']);
2022-02-27 22:57:09 +13:00
$this->assertIsInt($response['body']['total']);
$this->assertEquals(1, $response['body']['total']);
2021-09-23 19:01:10 +12:00
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2021-10-06 10:15:43 +13:00
'search' => $data['userId']
2021-09-21 20:22:13 +12:00
]);
2022-02-22 22:39:33 +13:00
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
2021-09-23 19:01:10 +12:00
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2021-10-08 04:49:47 +13:00
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'cursor' => 'unknown'
]);
$this->assertEquals(400, $response['headers']['status-code']);
2021-08-10 00:55:30 +12:00
}
2020-01-14 07:55:57 +13:00
/**
* @depends testCreateUser
*/
2022-05-24 02:54:50 +12:00
public function testGetUser(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
2021-10-06 10:15:43 +13:00
$this->assertEquals($user['body']['name'], 'Cristiano Ronaldo');
$this->assertEquals($user['body']['email'], 'cristiano.ronaldo@manchester-united.co.uk');
$this->assertEquals($user['body']['status'], true);
2020-01-14 07:55:57 +13:00
$this->assertGreaterThan(0, $user['body']['registration']);
$sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($sessions['headers']['status-code'], 200);
$this->assertIsArray($sessions['body']);
$users = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($users['headers']['status-code'], 200);
$this->assertIsArray($users['body']);
$this->assertIsArray($users['body']['users']);
2022-02-27 22:57:09 +13:00
$this->assertIsInt($users['body']['total']);
$this->assertGreaterThan(0, $users['body']['total']);
2020-01-14 07:55:57 +13:00
return $data;
}
2021-08-29 22:30:48 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserName(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/name', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Updated name',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['name'], 'Updated name');
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['name'], 'Updated name');
return $data;
}
2022-04-26 22:07:33 +12:00
/**
* @depends testUpdateUserName
*/
public function testUpdateUserNameSearch($data): void
{
$id = $data['userId'] ?? '';
$newName = 'Updated name';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $newName
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $id
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
}
2021-08-29 22:30:48 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserEmail(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/email', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => 'users.service@updated.com',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['email'], 'users.service@updated.com');
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['email'], 'users.service@updated.com');
return $data;
}
2022-04-26 22:07:33 +12:00
/**
* @depends testUpdateUserEmail
*/
public function testUpdateUserEmailSearch($data): void
{
$id = $data['userId'] ?? '';
$newEmail = '"users.service@updated.com"';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $newEmail
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $id
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
}
2021-08-29 22:30:48 +12:00
/**
* @depends testUpdateUserEmail
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserPassword(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/password', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'password' => 'password2',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertNotEmpty($user['body']['$id']);
$session = $this->client->call(Client::METHOD_POST, '/account/sessions', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'email' => 'users.service@updated.com',
'password' => 'password2'
]);
$this->assertEquals($session['headers']['status-code'], 201);
return $data;
}
2020-01-14 07:55:57 +13:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserStatus(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/status', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
'status' => false,
2020-01-14 07:55:57 +13:00
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['status'], false);
2020-01-14 07:55:57 +13:00
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['status'], false);
2020-01-14 07:55:57 +13:00
return $data;
}
2021-05-31 17:50:52 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateEmailVerification(array $data): array
2021-05-31 17:50:52 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/verification', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'emailVerification' => true,
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['emailVerification'], true);
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['emailVerification'], true);
return $data;
}
2020-01-14 07:55:57 +13:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateAndGetUserPrefs(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
2022-05-24 02:54:50 +12:00
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
2020-01-14 07:55:57 +13:00
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
'prefs' => [
2020-10-31 08:53:27 +13:00
'funcKey1' => 'funcValue1',
'funcKey2' => 'funcValue2',
2020-01-14 07:55:57 +13:00
],
]);
$this->assertEquals($user['headers']['status-code'], 200);
2020-10-31 08:53:27 +13:00
$this->assertEquals($user['body']['funcKey1'], 'funcValue1');
$this->assertEquals($user['body']['funcKey2'], 'funcValue2');
2020-01-14 07:55:57 +13:00
2022-05-24 02:54:50 +12:00
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/prefs', array_merge([
2021-01-11 00:56:48 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body'], [
'funcKey1' => 'funcValue1',
'funcKey2' => 'funcValue2',
]);
2020-01-20 09:38:00 +13:00
/**
* Test for FAILURE
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-20 09:38:00 +13:00
], $this->getHeaders()), [
'prefs' => 'bad-string',
]);
$this->assertEquals($user['headers']['status-code'], 400);
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-20 09:38:00 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 400);
2020-01-14 07:55:57 +13:00
return $data;
2020-01-14 07:30:13 +13:00
}
/**
* @depends testGetUser
*/
public function testGetLogs(array $data): void
{
/**
* Test for SUCCESS
*/
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-02-27 22:57:09 +13:00
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
2022-02-27 22:57:09 +13:00
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'offset' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-02-27 22:57:09 +13:00
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'offset' => 1,
'limit' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
2022-02-27 22:57:09 +13:00
$this->assertIsNumeric($logs['body']['total']);
}
2020-08-29 09:56:22 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testDeleteUser(array $data): array
2020-08-29 09:56:22 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 204);
/**
* Test for FAILURE
*/
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 404);
return $data;
}
2020-01-14 07:55:57 +13:00
// TODO add test for session delete
// TODO add test for all sessions delete
2022-05-24 02:54:50 +12:00
}