added tests

This commit is contained in:
ArnabChatterjee20k committed 2026-07-07 15:36:56 +05:30
1 parent 1daf39c737
commit 8d1c57d0e7
1 file changed
+39
@@ -776,6 +776,45 @@ trait DatabasesBase
$this->assertEquals($this->getDatabaseType(), $database['body']['type']);
}
public function testDatabaseStatus(): void
{
if ($this->getSide() === 'client') {
// Databases are created and read with a server API key.
$this->expectNotToPerformAssertions();
return;
}
$headers = [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
];
/**
* Test for SUCCESS
* A newly created database defaults to the "ready" status.
*/
$database = $this->client->call(Client::METHOD_POST, $this->getApiBasePath(), $headers, [
'databaseId' => ID::unique(),
'name' => 'Status Database',
]);
$this->assertEquals(201, $database['headers']['status-code']);
$this->assertArrayHasKey('status', $database['body']);
$this->assertEquals('ready', $database['body']['status']);
$databaseId = $database['body']['$id'];
/**
* The status is persisted and returned on read.
*/
$response = $this->client->call(Client::METHOD_GET, $this->getApiBasePath() . '/' . $databaseId, $headers);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertArrayHasKey('status', $response['body']);
$this->assertEquals('ready', $response['body']['status']);
}
public function testCreateCollection(): void
{
$data = $this->setupDatabase();