Improved e2e tests
This commit is contained in:
parent
173511d1b5
commit
327b82dffc
|
@ -279,7 +279,7 @@ trait AccountBase
|
|||
*/
|
||||
public function testGetAccountLogs($data):array
|
||||
{
|
||||
sleep(5);
|
||||
sleep(10);
|
||||
$session = (isset($data['session'])) ? $data['session'] : '';
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,12 +19,12 @@ class AccountCustomServerTest extends Scope
|
|||
$name = 'User Name';
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'X-Appwrite-Key' => $this->getProject()['apiKey'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], [
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
|
|
414
tests/e2e/Services/Avatars/AvatarsBase.php
Normal file
414
tests/e2e/Services/Avatars/AvatarsBase.php
Normal file
|
@ -0,0 +1,414 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Avatars;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
|
||||
trait AvatarsBase
|
||||
{
|
||||
public function testGetCreditCard():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/unknown', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 2001,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetBrowser():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/unknown', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 2001,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetFlag():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/unknown', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 2001,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetImage():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/unknown.png',
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(404, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'width' => 2001,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
// TODO Add test for non-image file (PDF, WORD)
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetFavicon():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
// 'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
// ], [
|
||||
// 'url' => 'https://www.bbc.com/',
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
// $this->assertNotEmpty($response['body']);
|
||||
|
||||
// $response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
// 'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
// ], [
|
||||
// 'url' => 'https://edition.cnn.com/',
|
||||
// ]);
|
||||
|
||||
// $this->assertEquals(200, $response['headers']['status-code']);
|
||||
// $this->assertEquals('image/x-icon; charset=UTF-8', $response['headers']['content-type']);
|
||||
// $this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'unknown-address',
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'http://unknown-address.test',
|
||||
]);
|
||||
|
||||
$this->assertEquals(404, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetQR():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
'margin' => 10,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
'margin' => 10,
|
||||
'download' => 1,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('attachment; filename="qr.png"', $response['headers']['content-disposition']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 1001,
|
||||
'margin' => 10,
|
||||
'download' => 1,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 400,
|
||||
'margin' => 11,
|
||||
'download' => 1,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 400,
|
||||
'margin' => 10,
|
||||
'download' => 2,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
14
tests/e2e/Services/Avatars/AvatarsConsoleClientTest.php
Normal file
14
tests/e2e/Services/Avatars/AvatarsConsoleClientTest.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Avatars;
|
||||
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class AvatarsConsoleClientTest extends Scope
|
||||
{
|
||||
use AvatarsBase;
|
||||
use ProjectConsole;
|
||||
use SideClient;
|
||||
}
|
14
tests/e2e/Services/Avatars/AvatarsCustomClientTest.php
Normal file
14
tests/e2e/Services/Avatars/AvatarsCustomClientTest.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Avatars;
|
||||
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class AvatarsCustomClientTest extends Scope
|
||||
{
|
||||
use AvatarsBase;
|
||||
use ProjectCustom;
|
||||
use SideClient;
|
||||
}
|
30
tests/e2e/Services/Avatars/AvatarsCustomServerTest.php
Normal file
30
tests/e2e/Services/Avatars/AvatarsCustomServerTest.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Avatars;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
|
||||
class AvatarsCustomServerTest extends Scope
|
||||
{
|
||||
use ProjectCustom;
|
||||
use SideServer;
|
||||
|
||||
public function testGetCreditCard():array
|
||||
{
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'X-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(401, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
236
tests/e2e/Services/Locale/LocaleBase.php
Normal file
236
tests/e2e/Services/Locale/LocaleBase.php
Normal file
|
@ -0,0 +1,236 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Locale;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
|
||||
trait LocaleBase
|
||||
{
|
||||
public function testGetLocale():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertArrayHasKey('ip', $response['body']);
|
||||
$this->assertArrayHasKey('countryCode', $response['body']);
|
||||
$this->assertArrayHasKey('country', $response['body']);
|
||||
$this->assertArrayHasKey('continent', $response['body']);
|
||||
$this->assertArrayHasKey('continentCode', $response['body']);
|
||||
$this->assertArrayHasKey('eu', $response['body']);
|
||||
$this->assertArrayHasKey('currency', $response['body']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetCountries():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(194, $response['body']);
|
||||
$this->assertEquals($response['body']['US'], 'United States');
|
||||
|
||||
// Test locale code change to ES
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => 'es',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(194, $response['body']);
|
||||
$this->assertEquals($response['body']['US'], 'Estados Unidos');
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetCountriesEU():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(28, $response['body']);
|
||||
$this->assertEquals($response['body']['DE'], 'Germany');
|
||||
|
||||
// Test locale code change to ES
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => 'es',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(28, $response['body']);
|
||||
$this->assertEquals($response['body']['DE'], 'Alemania');
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetCountriesPhones():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/phones', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(194, $response['body']);
|
||||
$this->assertEquals($response['body']['US'], 'United States +1');
|
||||
$this->assertEquals($response['body']['IL'], 'Israel +972');
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetContinents():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(7, $response['body']);
|
||||
$this->assertEquals($response['body']['NA'], 'North America');
|
||||
|
||||
// Test locale code change to ES
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => 'es',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(7, $response['body']);
|
||||
$this->assertEquals($response['body']['NA'], 'América del Norte');
|
||||
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testGetCurrencies():array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/currencies', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(117, $response['body']);
|
||||
$this->assertEquals($response['body'][0]['symbol'], '$');
|
||||
$this->assertEquals($response['body'][0]['name'], 'US Dollar');
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testLangaugaes(): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$languages = require('app/config/locales.php');
|
||||
$defaultCountries = require('app/config/locales/en.countries.php');
|
||||
$defaultContinents = require('app/config/locales/en.continents.php');
|
||||
|
||||
foreach ($languages as $lang) {
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
]);
|
||||
|
||||
foreach ($response['body'] as $i => $code) {
|
||||
$this->assertArrayHasKey($i, $defaultCountries, $i . ' country should be removed from ' . $lang);
|
||||
}
|
||||
|
||||
foreach (array_keys($defaultCountries) as $i => $code) {
|
||||
$this->assertArrayHasKey($code, $response['body'], $code . ' country is missing from ' . $lang . ' (total: ' . count($response['body']) . ')');
|
||||
}
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertCount(194, $response['body']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
]);
|
||||
|
||||
foreach ($response['body'] as $i => $code) {
|
||||
$this->assertArrayHasKey($i, $defaultContinents, $i . ' continent should be removed from ' . $lang);
|
||||
}
|
||||
|
||||
foreach (array_keys($defaultContinents) as $i => $code) {
|
||||
$this->assertArrayHasKey($code, $response['body'], $code . ' continent is missing from ' . $lang . ' (total: ' . count($response['body']) . ')');
|
||||
}
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertCount(7, $response['body']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
14
tests/e2e/Services/Locale/LocaleConsoleClientTest.php
Normal file
14
tests/e2e/Services/Locale/LocaleConsoleClientTest.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Locale;
|
||||
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectConsole;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class LocaleConsoleClientTest extends Scope
|
||||
{
|
||||
use LocaleBase;
|
||||
use ProjectConsole;
|
||||
use SideClient;
|
||||
}
|
14
tests/e2e/Services/Locale/LocaleCustomClientTest.php
Normal file
14
tests/e2e/Services/Locale/LocaleCustomClientTest.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Locale;
|
||||
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\SideClient;
|
||||
|
||||
class LocaleCustomClientTest extends Scope
|
||||
{
|
||||
use LocaleBase;
|
||||
use ProjectCustom;
|
||||
use SideClient;
|
||||
}
|
30
tests/e2e/Services/Locale/LocaleCustomServerTest.php
Normal file
30
tests/e2e/Services/Locale/LocaleCustomServerTest.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\E2E\Services\Locale;
|
||||
|
||||
use Tests\E2E\Client;
|
||||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
|
||||
class LocaleCustomServerTest extends Scope
|
||||
{
|
||||
use ProjectCustom;
|
||||
use SideServer;
|
||||
|
||||
public function testCreateLocale():array
|
||||
{
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'X-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(401, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -16,36 +16,36 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsCCReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -55,36 +55,36 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsBrowserReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -94,36 +94,36 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsFlagReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'width' => 300,
|
||||
'height' => 300,
|
||||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -133,30 +133,30 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsRemoteImageReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/images/apple.png',
|
||||
'width' => 300,
|
||||
|
@ -164,9 +164,9 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
'quality' => 30,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -176,15 +176,15 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsFaviconReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'url' => 'https://appwrite.io/',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -194,41 +194,41 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
*/
|
||||
public function testAvatarsQRReadSuccess(array $data): array
|
||||
{
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
'margin' => 10,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
], [
|
||||
'text' => 'url:https://appwrite.io/',
|
||||
'size' => 200,
|
||||
|
@ -236,10 +236,10 @@ class ProjectAvatarsTest extends BaseProjects
|
|||
'download' => 1,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $logo['headers']['status-code']);
|
||||
$this->assertEquals('attachment; filename="qr.png"', $logo['headers']['content-disposition']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
|
||||
$this->assertNotEmpty($logo['body']);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('attachment; filename="qr.png"', $response['headers']['content-disposition']);
|
||||
$this->assertEquals('image/png; charset=UTF-8', $response['headers']['content-type']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -16,18 +16,18 @@ class ProjectLocaleTest extends BaseProjects
|
|||
*/
|
||||
public function testLocaleReadSuccess(array $data): array
|
||||
{
|
||||
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$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']);
|
||||
$this->assertArrayHasKey('ip', $response['body']);
|
||||
$this->assertArrayHasKey('countryCode', $response['body']);
|
||||
$this->assertArrayHasKey('country', $response['body']);
|
||||
$this->assertArrayHasKey('continent', $response['body']);
|
||||
$this->assertArrayHasKey('continentCode', $response['body']);
|
||||
$this->assertArrayHasKey('eu', $response['body']);
|
||||
$this->assertArrayHasKey('currency', $response['body']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -37,28 +37,28 @@ class ProjectLocaleTest extends BaseProjects
|
|||
*/
|
||||
public function testLocaleCountriesReadSuccess(array $data): array
|
||||
{
|
||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($countries['headers']['status-code'], 200);
|
||||
$this->assertIsArray($countries['body']);
|
||||
$this->assertCount(194, $countries['body']);
|
||||
$this->assertEquals($countries['body']['US'], 'United States');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(194, $response['body']);
|
||||
$this->assertEquals($response['body']['US'], 'United States');
|
||||
|
||||
// Test locale code change to ES
|
||||
|
||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'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');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(194, $response['body']);
|
||||
$this->assertEquals($response['body']['US'], 'Estados Unidos');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -68,28 +68,28 @@ class ProjectLocaleTest extends BaseProjects
|
|||
*/
|
||||
public function testLocaleCountriesEUReadSuccess(array $data): array
|
||||
{
|
||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($countries['headers']['status-code'], 200);
|
||||
$this->assertIsArray($countries['body']);
|
||||
$this->assertCount(28, $countries['body']);
|
||||
$this->assertEquals($countries['body']['DE'], 'Germany');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(28, $response['body']);
|
||||
$this->assertEquals($response['body']['DE'], 'Germany');
|
||||
|
||||
// Test locale code change to ES
|
||||
|
||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'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');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(28, $response['body']);
|
||||
$this->assertEquals($response['body']['DE'], 'Alemania');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -99,27 +99,27 @@ class ProjectLocaleTest extends BaseProjects
|
|||
*/
|
||||
public function testLocaleContinentsReadSuccess(array $data): array
|
||||
{
|
||||
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($continents['headers']['status-code'], 200);
|
||||
$this->assertIsArray($continents['body']);
|
||||
$this->assertCount(7, $continents['body']);
|
||||
$this->assertEquals($continents['body']['NA'], 'North America');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(7, $response['body']);
|
||||
$this->assertEquals($response['body']['NA'], 'North America');
|
||||
|
||||
// Test locale code change to ES
|
||||
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'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');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(7, $response['body']);
|
||||
$this->assertEquals($response['body']['NA'], 'América del Norte');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -129,16 +129,16 @@ class ProjectLocaleTest extends BaseProjects
|
|||
*/
|
||||
public function testLocaleCurrenciesReadSuccess(array $data): array
|
||||
{
|
||||
$continents = $this->client->call(Client::METHOD_GET, '/locale/currencies', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/currencies', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
]);
|
||||
|
||||
$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');
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertIsArray($response['body']);
|
||||
$this->assertCount(117, $response['body']);
|
||||
$this->assertEquals($response['body'][0]['symbol'], '$');
|
||||
$this->assertEquals($response['body'][0]['name'], 'US Dollar');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -153,39 +153,39 @@ class ProjectLocaleTest extends BaseProjects
|
|||
$defaultContinents = require('app/config/locales/en.continents.php');
|
||||
|
||||
foreach ($languages as $key => $lang) {
|
||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
]);
|
||||
|
||||
foreach ($countries['body'] as $i => $code) {
|
||||
foreach ($response['body'] as $i => $code) {
|
||||
$this->assertArrayHasKey($i, $defaultCountries, $i . ' country should be removed from ' . $lang);
|
||||
}
|
||||
|
||||
foreach (array_keys($defaultCountries) as $i => $code) {
|
||||
$this->assertArrayHasKey($code, $countries['body'], $code . ' country is missing from ' . $lang . ' (total: ' . count($countries['body']) . ')');
|
||||
$this->assertArrayHasKey($code, $response['body'], $code . ' country is missing from ' . $lang . ' (total: ' . count($response['body']) . ')');
|
||||
}
|
||||
|
||||
$this->assertEquals($countries['headers']['status-code'], 200);
|
||||
$this->assertCount(194, $countries['body']);
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertCount(194, $response['body']);
|
||||
|
||||
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $data['projectUid'],
|
||||
'x-appwrite-project' => $this->getProject()['$uid'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
]);
|
||||
|
||||
foreach ($continents['body'] as $i => $code) {
|
||||
foreach ($response['body'] as $i => $code) {
|
||||
$this->assertArrayHasKey($i, $defaultContinents, $i . ' continent should be removed from ' . $lang);
|
||||
}
|
||||
|
||||
foreach (array_keys($defaultContinents) as $i => $code) {
|
||||
$this->assertArrayHasKey($code, $continents['body'], $code . ' continent is missing from ' . $lang . ' (total: ' . count($continents['body']) . ')');
|
||||
$this->assertArrayHasKey($code, $response['body'], $code . ' continent is missing from ' . $lang . ' (total: ' . count($response['body']) . ')');
|
||||
}
|
||||
|
||||
$this->assertEquals($continents['headers']['status-code'], 200);
|
||||
$this->assertCount(7, $continents['body']);
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertCount(7, $response['body']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
Loading…
Reference in a new issue