1
0
Fork 0
mirror of synced 2024-07-03 05:31:38 +12:00
appwrite/tests/e2e/ProjectAvatarsTest.php

247 lines
8.4 KiB
PHP
Raw Normal View History

2019-10-22 01:37:34 +13:00
<?php
namespace Tests\E2E;
use Tests\E2E\Client;
class ProjectAvatarsTest extends BaseProjects
{
2019-11-04 08:05:26 +13:00
public function testRegisterSuccess(): array
2019-10-22 01:37:34 +13:00
{
return $this->initProject([]);
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsCCReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 200,
'height' => 200,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 300,
'height' => 300,
'quality' => 30,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsBrowserReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 200,
'height' => 200,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 300,
'height' => 300,
'quality' => 30,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsFlagReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $data['projectUid'],
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 200,
'height' => 200,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $data['projectUid'],
], [
'width' => 300,
'height' => 300,
'quality' => 30,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsRemoteImageReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $data['projectUid'],
], [
'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']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $data['projectUid'],
], [
'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']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $data['projectUid'],
], [
'url' => 'https://appwrite.io/images/apple.png',
'width' => 300,
'height' => 300,
'quality' => 30,
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsFaviconReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
'x-appwrite-project' => $data['projectUid'],
], [
'url' => 'https://appwrite.io/',
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
/**
* @depends testRegisterSuccess
*/
2019-11-04 08:05:26 +13:00
public function testAvatarsQRReadSuccess(array $data): array
2019-10-22 01:37:34 +13:00
{
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $data['projectUid'],
], [
'text' => 'url:https://appwrite.io/',
]);
$this->assertEquals(200, $logo['headers']['status-code']);
$this->assertEquals('image/png; charset=UTF-8', $logo['headers']['content-type']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $data['projectUid'],
], [
'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']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $data['projectUid'],
], [
'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']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
$logo = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $data['projectUid'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 200,
'margin' => 10,
'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']);
2019-11-17 10:33:11 +13:00
$this->assertNotEmpty($logo['body']);
2019-10-22 01:37:34 +13:00
return $data;
}
}