1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Test for creating indexes

This commit is contained in:
kodumbeats 2021-06-14 15:54:49 -04:00
parent 1d2d869fa8
commit 80f41edf36

View file

@ -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([