1
0
Fork 0
mirror of synced 2024-10-01 17:58:02 +13:00
appwrite/tests/e2e/ProjectLocaleTest.php

144 lines
4.9 KiB
PHP
Raw Normal View History

2019-10-21 21:15:12 +13:00
<?php
namespace Tests\E2E;
use Tests\E2E\Client;
class ProjectLocaleTest extends BaseProjects
{
2019-11-04 08:05:26 +13:00
public function testRegisterSuccess(): array
2019-10-21 21:15:12 +13:00
{
return $this->initProject([]);
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testLocaleReadSuccess(array $data): array
2019-10-21 21:15:12 +13:00
{
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
//'x-appwrite-key' => $data['projectAPIKeySecret'],
]);
$this->assertArrayHasKey('ip', $locale['body']);
$this->assertArrayHasKey('countryCode', $locale['body']);
$this->assertArrayHasKey('country', $locale['body']);
$this->assertArrayHasKey('continent', $locale['body']);
$this->assertArrayHasKey('continentCode', $locale['body']);
$this->assertArrayHasKey('eu', $locale['body']);
$this->assertArrayHasKey('currency', $locale['body']);
2019-11-04 08:05:26 +13:00
2019-10-21 21:15:12 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testLocaleCountriesReadSuccess(array $data): array
2019-10-21 21:15:12 +13:00
{
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals($countries['headers']['status-code'], 200);
$this->assertIsArray($countries['body']);
$this->assertCount(194, $countries['body']);
$this->assertEquals($countries['body']['US'], 'United States');
2019-11-04 08:05:26 +13:00
2019-10-21 21:15:12 +13:00
// Test locale code change to ES
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
'x-appwrite-locale' => 'es',
]);
$this->assertEquals($countries['headers']['status-code'], 200);
$this->assertIsArray($countries['body']);
$this->assertCount(194, $countries['body']);
$this->assertEquals($countries['body']['US'], 'Estados Unidos');
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testLocaleCountriesEUReadSuccess(array $data): array
2019-10-21 21:30:16 +13:00
{
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals($countries['headers']['status-code'], 200);
$this->assertIsArray($countries['body']);
$this->assertCount(28, $countries['body']);
$this->assertEquals($countries['body']['DE'], 'Germany');
2019-11-04 08:05:26 +13:00
2019-10-21 21:30:16 +13:00
// Test locale code change to ES
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
'content-type' => 'application/json',
'x-appwrite-locale' => 'es',
]);
$this->assertEquals($countries['headers']['status-code'], 200);
$this->assertIsArray($countries['body']);
$this->assertCount(28, $countries['body']);
$this->assertEquals($countries['body']['DE'], 'Alemania');
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testLocaleContinentsReadSuccess(array $data): array
2019-10-21 21:15:12 +13:00
{
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals($continents['headers']['status-code'], 200);
$this->assertIsArray($continents['body']);
$this->assertCount(7, $continents['body']);
$this->assertEquals($continents['body']['NA'], 'North America');
2019-11-04 08:05:26 +13:00
2019-10-21 21:15:12 +13:00
// Test locale code change to ES
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
'x-appwrite-locale' => 'es',
]);
$this->assertEquals($continents['headers']['status-code'], 200);
$this->assertIsArray($continents['body']);
$this->assertCount(7, $continents['body']);
$this->assertEquals($continents['body']['NA'], 'América del Norte');
return $data;
}
2019-10-21 21:30:16 +13:00
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testLocaleCurrenciesReadSuccess(array $data): array
2019-10-21 21:30:16 +13:00
{
$continents = $this->client->call(Client::METHOD_GET, '/locale/currencies', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals($continents['headers']['status-code'], 200);
$this->assertIsArray($continents['body']);
$this->assertCount(117, $continents['body']);
$this->assertEquals($continents['body'][0]['symbol'], '$');
$this->assertEquals($continents['body'][0]['name'], 'US Dollar');
2019-11-04 08:05:26 +13:00
2019-10-21 21:30:16 +13:00
return $data;
}
2019-10-21 21:15:12 +13:00
}