diff --git a/tests/e2e/Services/Database/DatabaseBase.php b/tests/e2e/Services/Database/DatabaseBase.php index f7640fcff6..855cdf29f8 100644 --- a/tests/e2e/Services/Database/DatabaseBase.php +++ b/tests/e2e/Services/Database/DatabaseBase.php @@ -89,11 +89,34 @@ trait DatabaseBase return $data; } - // TODO@kodumbeats create and test indexes - /** * @depends testCreateAttributes */ + public function testCreateIndexes(array $data): array + { + $titleIndex = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/indexes', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'id' => 'titleIndex', + 'type' => 'fulltext', + 'attributes' => ['title'], + ]); + + $this->assertEquals($titleIndex['headers']['status-code'], 201); + $this->assertEquals($titleIndex['body']['$collection'], $data['moviesId']); + $this->assertEquals($titleIndex['body']['$id'], 'titleIndex'); + $this->assertEquals($titleIndex['body']['type'], 'fulltext'); + $this->assertCount(1, $titleIndex['body']['attributes']); + $this->assertEquals($titleIndex['body']['attributes'][0], 'title'); + + return $data; + } + + /** + * @depends testCreateIndexes + */ public function testCreateDocument(array $data):array { $document1 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([