1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Test enhancement

This commit is contained in:
peter279k 2019-11-04 03:05:26 +08:00
parent e4c7d1660a
commit 2c2bf9ad2f
10 changed files with 117 additions and 116 deletions

View file

@ -15,10 +15,10 @@ class BaseConsole extends TestCase
protected $demoEmail = '';
protected $demoPassword = '';
public function setUp()
protected function setUp(): void
{
$this->client = new Client();
$this->client
->setEndpoint($this->endpoint)
;
@ -27,7 +27,7 @@ class BaseConsole extends TestCase
$this->demoPassword = 'password.' . rand(0, 1000000);
}
public function tearDown()
protected function tearDown(): void
{
$this->client = null;
}
@ -49,12 +49,12 @@ class BaseConsole extends TestCase
return $response;
}
public function initProject(array $scopes) {
public function initProject(array $scopes): array {
$response = $this->register();
$this->assertEquals('http://localhost/success', $response['headers']['location']);
$this->assertEquals("", $response['body']);
$session = $this->client->parseCookie($response['headers']['set-cookie'])['a-session-console'];
$team = $this->client->call(Client::METHOD_POST, '/teams', [
@ -104,10 +104,10 @@ class BaseConsole extends TestCase
$this->assertNotEmpty($key['body']['secret']);
$user = $this->projectRegister($project['body']['$uid']);
$this->assertEquals('http://localhost/success', $user['headers']['location']);
$this->assertEquals("", $user['body']);
return [
'email' => $this->demoEmail,
'password' => $this->demoPassword,

View file

@ -12,7 +12,7 @@ class BaseProjects extends BaseConsole
protected $projectsDemoEmail = '';
protected $projectsDemoPassword = '';
public function setUp()
protected function setUp(): void
{
parent::setUp();
@ -20,7 +20,7 @@ class BaseProjects extends BaseConsole
$this->projectsDemoPassword = 'password.' . rand(0, 1000000);
}
public function tearDown()
protected function tearDown(): void
{
parent::tearDown();

View file

@ -54,9 +54,9 @@ class Client
*
* @param string $value
*
* @return Client
* @return self $this
*/
public function setProject($value)
public function setProject(string $value): self
{
$this->addHeader('X-Appwrite-Project', $value);
@ -70,9 +70,9 @@ class Client
*
* @param string $value
*
* @return Client
* @return self $this
*/
public function setKey($value)
public function setKey(string $value): self
{
$this->addHeader('X-Appwrite-Key', $value);
@ -84,9 +84,9 @@ class Client
*
* @param string $value
*
* @return Client
* @return self $this
*/
public function setLocale($value)
public function setLocale(string $value): self
{
$this->addHeader('X-Appwrite-Locale', $value);
@ -98,32 +98,31 @@ class Client
*
* @param string $value
*
* @return Client
* @return self $this
*/
public function setMode($value)
public function setMode(string $value): self
{
$this->addHeader('X-Appwrite-Mode', $value);
return $this;
}
/***
* @param bool $status
* @return $this
/**
* @param bool $status true
* @return self $this
*/
public function setSelfSigned($status = true)
public function setSelfSigned(bool $status = true): self
{
$this->selfSigned = $status;
return $this;
}
/***
* @param $endpoint
* @return $this
/**
* @param mixed $endpoint
* @return self $this
*/
public function setEndpoint($endpoint)
public function setEndpoint($endpoint): self
{
$this->endpoint = $endpoint;
@ -131,13 +130,15 @@ class Client
}
/**
* @param $key
* @param $value
* @param string $key
* @param string $value
*
* @return self $this
*/
public function addHeader($key, $value)
public function addHeader(string $key, string $value): self
{
$this->headers[strtolower($key)] = strtolower($value);
return $this;
}
@ -153,7 +154,7 @@ class Client
* @return array|string
* @throws Exception
*/
public function call($method, $path = '', $headers = array(), array $params = array())
public function call(string $method, string $path = '', array $headers = [], array $params = [])
{
$headers = array_merge($this->headers, $headers);
$ch = curl_init($this->endpoint . $path . (($method == self::METHOD_GET && !empty($params)) ? '?' . http_build_query($params) : ''));
@ -238,7 +239,7 @@ class Client
* @param string $cookie
* @return array
*/
public function parseCookie($cookie)
public function parseCookie(string $cookie): array
{
$cookies = [];
@ -254,7 +255,7 @@ class Client
* @param string $prefix
* @return array
*/
protected function flatten(array $data, $prefix = '')
protected function flatten(array $data, string $prefix = ''): array
{
$output = [];

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ConsoleHealthTest extends BaseConsole
{
public function testHTTPSuccess()
public function testHTTPSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health', [
'origin' => 'http://localhost',
@ -17,7 +17,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertEquals('OK', $response['body']['status']);
}
public function testDBSuccess()
public function testDBSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/db', [
'origin' => 'http://localhost',
@ -28,7 +28,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertEquals('OK', $response['body']['status']);
}
public function testCacheSuccess()
public function testCacheSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/db', [
'origin' => 'http://localhost',
@ -39,7 +39,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertEquals('OK', $response['body']['status']);
}
public function testTimeSuccess()
public function testTimeSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/time', [
'origin' => 'http://localhost',
@ -54,7 +54,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertLessThan(10, $response['body']['diff']);
}
public function testWebhooksSuccess()
public function testWebhooksSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/webhooks', [
'origin' => 'http://localhost',
@ -66,7 +66,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertLessThan(10, $response['body']['size']);
}
public function xtestStorageLocalSuccess()
public function xtestStorageLocalSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/storage/local', [
'origin' => 'http://localhost',
@ -77,7 +77,7 @@ class ConsoleHealthTest extends BaseConsole
$this->assertEquals('OK', $response['body']['status']);
}
public function testStorageAntiVirusSuccess()
public function testStorageAntiVirusSuccess(): void
{
$response = $this->client->call(Client::METHOD_GET, '/health/storage/anti-virus', [
'origin' => 'http://localhost',

View file

@ -6,13 +6,13 @@ use Tests\E2E\Client;
class ConsoleProjectsTest extends BaseConsole
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
$response = $this->register();
$this->assertEquals('http://localhost/success', $response['headers']['location']);
$this->assertEquals("", $response['body']);
$session = $this->client->parseCookie($response['headers']['set-cookie'])['a-session-console'];
return [
@ -25,7 +25,7 @@ class ConsoleProjectsTest extends BaseConsole
/**
* @depends testRegisterSuccess
*/
public function testProjectsList($data)
public function testProjectsList($data): void
{
$response = $this->client->call(Client::METHOD_GET, '/projects', [
'origin' => 'http://localhost',
@ -40,7 +40,7 @@ class ConsoleProjectsTest extends BaseConsole
/**
* @depends testRegisterSuccess
*/
public function testProjectsCreateSuccess($data)
public function testProjectsCreateSuccess(array $data): array
{
$team = $this->client->call(Client::METHOD_POST, '/teams', [
'origin' => 'http://localhost',
@ -83,7 +83,7 @@ class ConsoleProjectsTest extends BaseConsole
/**
* @depends testProjectsCreateSuccess
*/
public function testProjectsUpdateSuccess($data)
public function testProjectsUpdateSuccess(array $data): void
{
$response = $this->client->call(Client::METHOD_POST, '/projects', [
'origin' => 'http://localhost',

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ConsoleTest extends BaseConsole
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
$response = $this->register();
@ -22,7 +22,7 @@ class ConsoleTest extends BaseConsole
/**
* @depends testRegisterSuccess
*/
public function testLoginSuccess($data)
public function testLoginSuccess(array $data): array
{
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
'origin' => 'http://localhost',
@ -49,7 +49,7 @@ class ConsoleTest extends BaseConsole
/**
* @depends testLoginSuccess
*/
public function testAccountSuccess($data)
public function testAccountSuccess(array $data): array
{
$response = $this->client->call(Client::METHOD_GET, '/account', [
'origin' => 'http://localhost',
@ -72,7 +72,7 @@ class ConsoleTest extends BaseConsole
/**
* @depends testAccountSuccess
*/
public function testLogoutSuccess($data)
public function testLogoutSuccess(array $data): void
{
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
'origin' => 'http://localhost',
@ -84,7 +84,7 @@ class ConsoleTest extends BaseConsole
$this->assertEquals('success', $response['body']['result']);
}
public function testLogoutFailure()
public function testLogoutFailure(): void
{
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
'origin' => 'http://localhost',

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ProjectAvatarsTest extends BaseProjects
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
return $this->initProject([]);
}
@ -14,7 +14,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsCCReadSuccess($data)
public function testAvatarsCCReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $data['projectUid'],
@ -53,7 +53,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsBrowserReadSuccess($data)
public function testAvatarsBrowserReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $data['projectUid'],
@ -92,7 +92,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsFlagReadSuccess($data)
public function testAvatarsFlagReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $data['projectUid'],
@ -131,7 +131,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsRemoteImageReadSuccess($data)
public function testAvatarsRemoteImageReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $data['projectUid'],
@ -174,7 +174,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsFaviconReadSuccess($data)
public function testAvatarsFaviconReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
'x-appwrite-project' => $data['projectUid'],
@ -192,7 +192,7 @@ class ProjectAvatarsTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testAvatarsQRReadSuccess($data)
public function testAvatarsQRReadSuccess(array $data): array
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $data['projectUid'],

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ProjectDatabaseTest extends BaseProjects
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
return $this->initProject(['collections.read', 'collections.write', 'documents.read', 'documents.write',]);
}
@ -14,7 +14,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testCollectionCreateSuccess($data)
public function testCollectionCreateSuccess(array $data): array
{
$actors = $this->client->call(Client::METHOD_POST, '/database', [
'content-type' => 'application/json',
@ -50,9 +50,9 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertIsArray($actors['body']['$permissions']);
$this->assertIsArray($actors['body']['$permissions']['read']);
$this->assertIsArray($actors['body']['$permissions']['write']);
$this->assertEquals(count($actors['body']['$permissions']['read']), 1);
$this->assertEquals(count($actors['body']['$permissions']['write']), 2);
$this->assertCount(1, $actors['body']['$permissions']['read']);
$this->assertCount(2, $actors['body']['$permissions']['write']);
$movies = $this->client->call(Client::METHOD_POST, '/database', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
@ -96,8 +96,8 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertIsArray($movies['body']['$permissions']);
$this->assertIsArray($movies['body']['$permissions']['read']);
$this->assertIsArray($movies['body']['$permissions']['write']);
$this->assertEquals(count($movies['body']['$permissions']['read']), 1);
$this->assertEquals(count($movies['body']['$permissions']['write']), 2);
$this->assertCount(1, $movies['body']['$permissions']['read']);
$this->assertCount(2, $movies['body']['$permissions']['write']);
return array_merge($data, ['moviesId' => $movies['body']['$uid'], 'actorsId' => $actors['body']['$uid']]);
}
@ -105,7 +105,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testCollectionCreateSuccess
*/
public function testDocumentCreateSuccess($data)
public function testDocumentCreateSuccess(array $data): array
{
$document1 = $this->client->call(Client::METHOD_POST, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -205,10 +205,10 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertIsArray($document1['body']['$permissions']);
$this->assertIsArray($document1['body']['$permissions']['read']);
$this->assertIsArray($document1['body']['$permissions']['write']);
$this->assertEquals(count($document1['body']['$permissions']['read']), 0);
$this->assertEquals(count($document1['body']['$permissions']['write']), 0);
$this->assertEquals(count($document1['body']['actors']), 2);
$this->assertCount(0, $document1['body']['$permissions']['read']);
$this->assertCount(0, $document1['body']['$permissions']['write']);
$this->assertCount(2, $document1['body']['actors']);
$this->assertEquals($document2['headers']['status-code'], 201);
$this->assertEquals($document2['body']['$collection'], $data['moviesId']);
$this->assertEquals($document2['body']['name'], 'Spider-Man: Far From Home');
@ -216,16 +216,16 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertIsArray($document2['body']['$permissions']);
$this->assertIsArray($document2['body']['$permissions']['read']);
$this->assertIsArray($document2['body']['$permissions']['write']);
$this->assertEquals(count($document2['body']['$permissions']['read']), 0);
$this->assertEquals(count($document2['body']['$permissions']['write']), 0);
$this->assertEquals(count($document2['body']['actors']), 3);
$this->assertCount(0, $document2['body']['$permissions']['read']);
$this->assertCount(0, $document2['body']['$permissions']['write']);
$this->assertCount(3, $document2['body']['actors']);
$this->assertEquals($document2['body']['actors'][0]['firstName'], 'Tom');
$this->assertEquals($document2['body']['actors'][0]['lastName'], 'Holland');
$this->assertEquals($document2['body']['actors'][1]['firstName'], 'Zendaya');
$this->assertEquals($document2['body']['actors'][1]['lastName'], 'Maree Stoermer');
$this->assertEquals($document2['body']['actors'][2]['firstName'], 'Samuel');
$this->assertEquals($document2['body']['actors'][2]['lastName'], 'Jackson');
$this->assertEquals($document3['headers']['status-code'], 201);
$this->assertEquals($document3['body']['$collection'], $data['moviesId']);
$this->assertEquals($document3['body']['name'], 'Spider-Man: Homecoming');
@ -233,23 +233,23 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertIsArray($document3['body']['$permissions']);
$this->assertIsArray($document3['body']['$permissions']['read']);
$this->assertIsArray($document3['body']['$permissions']['write']);
$this->assertEquals(count($document3['body']['$permissions']['read']), 0);
$this->assertEquals(count($document3['body']['$permissions']['write']), 0);
$this->assertEquals(count($document3['body']['actors']), 2);
$this->assertCount(0, $document3['body']['$permissions']['read']);
$this->assertCount(0, $document3['body']['$permissions']['write']);
$this->assertCount(2, $document3['body']['actors']);
$this->assertEquals($document3['body']['actors'][0]['firstName'], 'Tom');
$this->assertEquals($document3['body']['actors'][0]['lastName'], 'Holland');
$this->assertEquals($document3['body']['actors'][1]['firstName'], 'Zendaya');
$this->assertEquals($document3['body']['actors'][1]['lastName'], 'Maree Stoermer');
$this->assertEquals($document4['headers']['status-code'], 400);
return $data;
}
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsListSuccessOrderAndCasting($data)
public function testDocumentsListSuccessOrderAndCasting(array $data): void
{
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -260,7 +260,7 @@ class ProjectDatabaseTest extends BaseProjects
'order-type' => 'ASC',
'order-cast' => 'int',
]);
$this->assertEquals(1944, $documents['body']['documents'][0]['releaseYear']);
$this->assertEquals(2017, $documents['body']['documents'][1]['releaseYear']);
$this->assertEquals(2019, $documents['body']['documents'][2]['releaseYear']);
@ -275,7 +275,7 @@ class ProjectDatabaseTest extends BaseProjects
'order-type' => 'DESC',
'order-cast' => 'int',
]);
$this->assertEquals(1944, $documents['body']['documents'][2]['releaseYear']);
$this->assertEquals(2017, $documents['body']['documents'][1]['releaseYear']);
$this->assertEquals(2019, $documents['body']['documents'][0]['releaseYear']);
@ -285,7 +285,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsListSuccessLimitAndOffset($data)
public function testDocumentsListSuccessLimitAndOffset(array $data): void
{
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -297,7 +297,7 @@ class ProjectDatabaseTest extends BaseProjects
'order-type' => 'ASC',
'order-cast' => 'int',
]);
$this->assertEquals(1944, $documents['body']['documents'][0]['releaseYear']);
$this->assertCount(1, $documents['body']['documents']);
@ -312,7 +312,7 @@ class ProjectDatabaseTest extends BaseProjects
'order-type' => 'ASC',
'order-cast' => 'int',
]);
$this->assertEquals(2017, $documents['body']['documents'][0]['releaseYear']);
$this->assertEquals(2019, $documents['body']['documents'][1]['releaseYear']);
$this->assertCount(2, $documents['body']['documents']);
@ -321,7 +321,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsListSuccessFirstAndLast($data)
public function testDocumentsListSuccessFirstAndLast(array $data): void
{
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -334,7 +334,7 @@ class ProjectDatabaseTest extends BaseProjects
'order-cast' => 'int',
'first' => true,
]);
$this->assertEquals(1944, $documents['body']['releaseYear']);
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
@ -349,14 +349,14 @@ class ProjectDatabaseTest extends BaseProjects
'order-cast' => 'int',
'last' => true,
]);
$this->assertEquals(2019, $documents['body']['releaseYear']);
}
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsListSuccessSerach($data)
public function testDocumentsListSuccessSearch(array $data): void
{
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -396,7 +396,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsListSuccessFilters($data)
public function testDocumentsListSuccessFilters(array $data): void
{
$documents = $this->client->call(Client::METHOD_GET, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -443,7 +443,7 @@ class ProjectDatabaseTest extends BaseProjects
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsUpdateSuccess($data)
public function testDocumentsUpdateSuccess(array $data): void
{
$document = $this->client->call(Client::METHOD_POST, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -462,7 +462,7 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertEquals($document['headers']['status-code'], 201);
$this->assertEquals($document['body']['name'], 'Thor: Ragnaroc');
$this->assertEquals($document['body']['releaseYear'], 2017);
$document = $this->client->call(Client::METHOD_PATCH, '/database/' . $collection . '/documents/' . $id, [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
@ -476,7 +476,7 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertEquals($document['headers']['status-code'], 200);
$this->assertEquals($document['body']['name'], 'Thor: Ragnarok');
$this->assertEquals($document['body']['releaseYear'], 2017);
$document = $this->client->call(Client::METHOD_GET, '/database/' . $collection . '/documents/' . $id, [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
@ -489,13 +489,13 @@ class ProjectDatabaseTest extends BaseProjects
$this->assertEquals($document['headers']['status-code'], 200);
$this->assertEquals($document['body']['name'], 'Thor: Ragnarok');
$this->assertEquals($document['body']['releaseYear'], 2017);
}
/**
* @depends testDocumentCreateSuccess
*/
public function testDocumentsDeleteSuccess($data)
public function testDocumentsDeleteSuccess(array $data): void
{
$document = $this->client->call(Client::METHOD_POST, '/database/' . $data['moviesId'] . '/documents', [
'content-type' => 'application/json',
@ -512,7 +512,7 @@ class ProjectDatabaseTest extends BaseProjects
$collection = $document['body']['$collection'];
$this->assertEquals($document['headers']['status-code'], 201);
$document = $this->client->call(Client::METHOD_GET, '/database/' . $collection . '/documents/' . $id, [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ProjectLocaleTest extends BaseProjects
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
return $this->initProject([]);
}
@ -14,7 +14,7 @@ class ProjectLocaleTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testLocaleReadSuccess($data)
public function testLocaleReadSuccess(array $data): array
{
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
'content-type' => 'application/json',
@ -29,14 +29,14 @@ class ProjectLocaleTest extends BaseProjects
$this->assertArrayHasKey('continentCode', $locale['body']);
$this->assertArrayHasKey('eu', $locale['body']);
$this->assertArrayHasKey('currency', $locale['body']);
return $data;
}
/**
* @depends testRegisterSuccess
*/
public function testLocaleCountriesReadSuccess($data)
public function testLocaleCountriesReadSuccess(array $data): array
{
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
@ -47,7 +47,7 @@ class ProjectLocaleTest extends BaseProjects
$this->assertIsArray($countries['body']);
$this->assertCount(194, $countries['body']);
$this->assertEquals($countries['body']['US'], 'United States');
// Test locale code change to ES
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
@ -66,7 +66,7 @@ class ProjectLocaleTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testLocaleCountriesEUReadSuccess($data)
public function testLocaleCountriesEUReadSuccess(array $data): array
{
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
'content-type' => 'application/json',
@ -77,7 +77,7 @@ class ProjectLocaleTest extends BaseProjects
$this->assertIsArray($countries['body']);
$this->assertCount(28, $countries['body']);
$this->assertEquals($countries['body']['DE'], 'Germany');
// Test locale code change to ES
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
@ -96,7 +96,7 @@ class ProjectLocaleTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testLocaleContinentsReadSuccess($data)
public function testLocaleContinentsReadSuccess(array $data): array
{
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
@ -107,7 +107,7 @@ class ProjectLocaleTest extends BaseProjects
$this->assertIsArray($continents['body']);
$this->assertCount(7, $continents['body']);
$this->assertEquals($continents['body']['NA'], 'North America');
// Test locale code change to ES
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
@ -125,7 +125,7 @@ class ProjectLocaleTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testLocaleCurrenciesReadSuccess($data)
public function testLocaleCurrenciesReadSuccess(array $data): array
{
$continents = $this->client->call(Client::METHOD_GET, '/locale/currencies', [
'content-type' => 'application/json',
@ -137,7 +137,7 @@ class ProjectLocaleTest extends BaseProjects
$this->assertCount(117, $continents['body']);
$this->assertEquals($continents['body'][0]['symbol'], '$');
$this->assertEquals($continents['body'][0]['name'], 'US Dollar');
return $data;
}
}

View file

@ -6,7 +6,7 @@ use Tests\E2E\Client;
class ProjectUsersTest extends BaseProjects
{
public function testRegisterSuccess()
public function testRegisterSuccess(): array
{
return $this->initProject(['users.read', 'users.write']);
}
@ -14,7 +14,7 @@ class ProjectUsersTest extends BaseProjects
/**
* @depends testRegisterSuccess
*/
public function testUserCreateSuccess($data)
public function testUserCreateSuccess(array $data): array
{
$user = $this->client->call(Client::METHOD_POST, '/users', [
'content-type' => 'application/json',
@ -32,28 +32,28 @@ class ProjectUsersTest extends BaseProjects
$this->assertEquals($user['body']['status'], 0);
$this->assertGreaterThan(0, $user['body']['registration']);
$this->assertIsArray($user['body']['roles']);
return array_merge($data, ['userId' => $user['body']['$uid']]);
}
/**
* @depends testUserCreateSuccess
*/
public function testUserReadSuccess($data)
public function testUserReadSuccess(array $data): array
{
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
'x-appwrite-key' => $data['projectAPIKeySecret'],
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['name'], 'Project User');
$this->assertEquals($user['body']['email'], 'users.service@example.com');
$this->assertEquals($user['body']['status'], 0);
$this->assertGreaterThan(0, $user['body']['registration']);
$this->assertIsArray($user['body']['roles']);
$sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
@ -62,7 +62,7 @@ class ProjectUsersTest extends BaseProjects
$this->assertEquals($sessions['headers']['status-code'], 200);
$this->assertIsArray($sessions['body']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
@ -106,7 +106,7 @@ class ProjectUsersTest extends BaseProjects
/**
* @depends testUserReadSuccess
*/
public function testUserUpdateStatusSuccess($data)
public function testUserUpdateStatusSuccess(array $data): array
{
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/status', [
'content-type' => 'application/json',
@ -134,7 +134,7 @@ class ProjectUsersTest extends BaseProjects
/**
* @depends testUserReadSuccess
*/
public function testUserUpdatePrefsSuccess($data)
public function testUserUpdatePrefsSuccess(array $data): array
{
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', [
'content-type' => 'application/json',