1
0
Fork 0
mirror of synced 2024-09-08 05:42:15 +12:00
appwrite/tests/e2e/Services/GraphQL/LocalizationTest.php

166 lines
5.6 KiB
PHP
Raw Normal View History

2022-07-04 18:16:16 +12:00
<?php
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
2022-09-22 20:29:42 +12:00
class LocalizationTest extends Scope
2022-07-04 18:16:16 +12:00
{
use ProjectCustom;
use SideServer;
2022-09-22 20:29:42 +12:00
use Base;
2022-07-04 18:16:16 +12:00
public function testGetLocale(): array
{
$projectId = $this->getProject()['$id'];
2022-07-19 13:41:31 +12:00
$query = \urlencode($this->getQuery(self::$GET_LOCALE));
2022-07-04 18:16:16 +12:00
2022-07-19 13:31:14 +12:00
$locale = $this->client->call(Client::METHOD_GET, '/graphql?query=' . $query, \array_merge([
2022-07-04 18:16:16 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
2022-07-19 13:31:14 +12:00
], $this->getHeaders()));
2022-07-04 18:16:16 +12:00
$this->assertIsArray($locale['body']['data']);
$this->assertArrayNotHasKey('errors', $locale['body']);
$locale = $locale['body']['data']['localeGet'];
$this->assertIsArray($locale);
return $locale;
}
public function testGetCountries(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_COUNTRIES);
$graphQLPayload = [
'query' => $query,
];
$countries = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($countries['body']['data']);
$this->assertArrayNotHasKey('errors', $countries['body']);
2022-09-21 19:03:28 +12:00
$countries = $countries['body']['data']['localeListCountries'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($countries);
$this->assertGreaterThan(0, \count($countries));
return $countries;
}
public function testGetCountriesEU(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_EU_COUNTRIES);
$graphQLPayload = [
'query' => $query,
];
$countries = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($countries['body']['data']);
$this->assertArrayNotHasKey('errors', $countries['body']);
2022-09-21 19:03:28 +12:00
$countries = $countries['body']['data']['localeListCountriesEU'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($countries);
$this->assertGreaterThan(0, \count($countries));
return $countries;
}
public function testGetCountriesPhones(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_COUNTRY_PHONE_CODES);
$graphQLPayload = [
'query' => $query,
];
$countries = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($countries['body']['data']);
$this->assertArrayNotHasKey('errors', $countries['body']);
2022-09-21 19:03:28 +12:00
$countries = $countries['body']['data']['localeListCountriesPhones'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($countries);
$this->assertGreaterThan(0, \count($countries));
return $countries;
}
public function testGetContinents(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_CONTINENTS);
$graphQLPayload = [
'query' => $query,
];
$continents = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($continents['body']['data']);
$this->assertArrayNotHasKey('errors', $continents['body']);
2022-09-21 19:03:28 +12:00
$continents = $continents['body']['data']['localeListContinents'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($continents);
$this->assertGreaterThan(0, \count($continents));
return $continents;
}
public function testGetCurrencies(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_CURRENCIES);
$graphQLPayload = [
'query' => $query,
];
$currencies = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($currencies['body']['data']);
$this->assertArrayNotHasKey('errors', $currencies['body']);
2022-09-21 19:03:28 +12:00
$currencies = $currencies['body']['data']['localeListCurrencies'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($currencies);
$this->assertGreaterThan(0, \count($currencies));
return $currencies;
}
public function testGetLanguages(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$LIST_LANGUAGES);
$graphQLPayload = [
'query' => $query,
];
$languages = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($languages['body']['data']);
$this->assertArrayNotHasKey('errors', $languages['body']);
2022-09-21 19:03:28 +12:00
$languages = $languages['body']['data']['localeListLanguages'];
2022-07-04 18:16:16 +12:00
$this->assertIsArray($languages);
$this->assertGreaterThan(0, \count($languages));
return $languages;
}
2022-07-06 15:51:37 +12:00
}