Add locale service tests
This commit is contained in:
parent
ac10ed31ac
commit
c22ffc1dfe
1 changed files with 169 additions and 0 deletions
169
tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php
Normal file
169
tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\E2E\Services\GraphQL;
|
||||||
|
|
||||||
|
use Tests\E2E\Client;
|
||||||
|
use Tests\E2E\Scopes\ProjectCustom;
|
||||||
|
use Tests\E2E\Scopes\Scope;
|
||||||
|
use Tests\E2E\Scopes\SideClient;
|
||||||
|
use Tests\E2E\Scopes\SideServer;
|
||||||
|
|
||||||
|
class GraphQLLocalizationTest extends Scope
|
||||||
|
{
|
||||||
|
use ProjectCustom;
|
||||||
|
use SideServer;
|
||||||
|
use GraphQLBase;
|
||||||
|
|
||||||
|
public function testGetLocale(): array
|
||||||
|
{
|
||||||
|
$projectId = $this->getProject()['$id'];
|
||||||
|
$query = $this->getQuery(self::$GET_LOCALE);
|
||||||
|
$graphQLPayload = [
|
||||||
|
'query' => $query,
|
||||||
|
];
|
||||||
|
|
||||||
|
$locale = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $projectId,
|
||||||
|
], $this->getHeaders()), $graphQLPayload);
|
||||||
|
|
||||||
|
$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']);
|
||||||
|
$countries = $countries['body']['data']['localeGetCountries'];
|
||||||
|
$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']);
|
||||||
|
$countries = $countries['body']['data']['localeGetCountriesEU'];
|
||||||
|
$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']);
|
||||||
|
$countries = $countries['body']['data']['localeGetCountriesPhones'];
|
||||||
|
$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']);
|
||||||
|
$continents = $continents['body']['data']['localeGetContinents'];
|
||||||
|
$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']);
|
||||||
|
$currencies = $currencies['body']['data']['localeGetCurrencies'];
|
||||||
|
$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']);
|
||||||
|
$languages = $languages['body']['data']['localeGetLanguages'];
|
||||||
|
$this->assertIsArray($languages);
|
||||||
|
$this->assertGreaterThan(0, \count($languages));
|
||||||
|
|
||||||
|
return $languages;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue