2024-10-04 22:23:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\E2E\General;
|
|
|
|
|
|
|
|
|
|
use Tests\E2E\Client;
|
|
|
|
|
use Tests\E2E\Scopes\ProjectCustom;
|
|
|
|
|
use Tests\E2E\Scopes\Scope;
|
|
|
|
|
use Tests\E2E\Scopes\SideClient;
|
|
|
|
|
|
|
|
|
|
class PingTest extends Scope
|
|
|
|
|
{
|
|
|
|
|
use ProjectCustom;
|
|
|
|
|
use SideClient;
|
|
|
|
|
|
|
|
|
|
public function testPing()
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Test for SUCCESS
|
|
|
|
|
*/
|
|
|
|
|
// Without user session
|
2024-10-07 13:00:19 +00:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/ping', [
|
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2024-10-04 22:23:18 +00:00
|
|
|
]);
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
|
$this->assertEquals('Pong!', $response['body']);
|
|
|
|
|
|
|
|
|
|
// With user session
|
2024-10-07 13:00:19 +00:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/ping', array_merge([
|
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
|
], $this->getHeaders()));
|
2024-10-04 22:23:18 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
|
$this->assertEquals('Pong!', $response['body']);
|
|
|
|
|
|
|
|
|
|
// With API key
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/ping', [
|
2024-10-07 13:00:19 +00:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2024-10-04 22:23:18 +00:00
|
|
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
|
|
|
|
]);
|
|
|
|
|
|
2024-10-07 14:58:34 +00:00
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
|
$this->assertEquals('Pong!', $response['body']);
|
|
|
|
|
|
2024-10-04 22:23:18 +00:00
|
|
|
/**
|
|
|
|
|
* Test for FAILURE
|
|
|
|
|
*/
|
|
|
|
|
// Fake project ID
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/ping', \array_merge([
|
2024-10-07 13:00:19 +00:00
|
|
|
'x-appwrite-project' => 'fake-project-id',
|
|
|
|
|
], $this->getHeaders()));
|
2024-10-04 22:23:18 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
|
|
|
|
$this->assertNotContains('Pong!', $response['body']);
|
|
|
|
|
}
|
|
|
|
|
}
|