1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00
appwrite/tests/e2e/General/HTTPTest.php

50 lines
2 KiB
PHP
Raw Normal View History

2020-07-08 09:14:40 +12:00
<?php
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectNone;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideNone;
class HTTPTest extends Scope
{
use ProjectNone;
use SideNone;
public function testOptions()
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_OPTIONS, '/', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
]), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('Appwrite', $response['headers']['server']);
$this->assertEquals('GET, POST, PUT, PATCH, DELETE', $response['headers']['access-control-allow-methods']);
$this->assertEquals('Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma, X-Fallback-Cookies', $response['headers']['access-control-allow-headers']);
$this->assertEquals('X-Fallback-Cookies', $response['headers']['access-control-expose-headers']);
$this->assertEquals('http://localhost', $response['headers']['access-control-allow-origin']);
$this->assertEquals('true', $response['headers']['access-control-allow-credentials']);
$this->assertEmpty($response['body']);
}
public function testError()
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/error', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
]), []);
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertEquals('Not Found', $response['body']['message']);
$this->assertEquals(404, $response['body']['code']);
$this->assertEquals('dev', $response['body']['version']);
}
}