appwrite/tests/e2e/Services/Databases/DocumentsDB/DatabasesBase.php
2025-09-19 19:44:46 +05:30

31 lines
939 B
PHP

<?php
namespace Tests\E2E\Services\Databases\DocumentsDB;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
trait DatabasesBase
{
public function testCreateDatabase(): array
{
/**
* Test for SUCCESS
*/
$database = $this->client->call(Client::METHOD_POST, '/documentsdb', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'databaseId' => ID::unique(),
'name' => 'Test Database'
]);
$this->assertNotEmpty($database['body']['$id']);
$this->assertEquals(201, $database['headers']['status-code']);
$this->assertEquals('Test Database', $database['body']['name']);
$this->assertEquals('legacy', $database['body']['type']);
return ['databaseId' => $database['body']['$id']];
}
}