tests(database): after pagination tests
This commit is contained in:
parent
40ecd0688a
commit
f7be5cd7b1
|
@ -316,7 +316,7 @@ trait DatabaseBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'orderAfter' => $base['body']['documents'][0]['$id']
|
||||
'after' => $base['body']['documents'][0]['$id']
|
||||
]);
|
||||
|
||||
$this->assertEquals($base['body']['documents'][1]['$id'], $documents['body']['documents'][0]['$id']);
|
||||
|
@ -327,7 +327,7 @@ trait DatabaseBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'orderAfter' => $base['body']['documents'][2]['$id']
|
||||
'after' => $base['body']['documents'][2]['$id']
|
||||
]);
|
||||
|
||||
$this->assertEmpty($documents['body']['documents']);
|
||||
|
@ -354,7 +354,7 @@ trait DatabaseBase
|
|||
], $this->getHeaders()), [
|
||||
'orderAttributes' => ['releaseYear'],
|
||||
'orderTypes' => ['ASC'],
|
||||
'orderAfter' => $base['body']['documents'][1]['$id']
|
||||
'after' => $base['body']['documents'][1]['$id']
|
||||
]);
|
||||
|
||||
$this->assertEquals($base['body']['documents'][2]['$id'], $documents['body']['documents'][0]['$id']);
|
||||
|
@ -382,7 +382,7 @@ trait DatabaseBase
|
|||
], $this->getHeaders()), [
|
||||
'orderAttributes' => ['releaseYear'],
|
||||
'orderTypes' => ['DESC'],
|
||||
'orderAfter' => $base['body']['documents'][1]['$id']
|
||||
'after' => $base['body']['documents'][1]['$id']
|
||||
]);
|
||||
|
||||
$this->assertEquals($base['body']['documents'][2]['$id'], $documents['body']['documents'][0]['$id']);
|
||||
|
@ -395,7 +395,7 @@ trait DatabaseBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'orderAfter' => 'unknown'
|
||||
'after' => 'unknown'
|
||||
]);
|
||||
|
||||
$this->assertEquals($documents['headers']['status-code'], 400);
|
||||
|
|
|
@ -13,6 +13,86 @@ class DatabaseCustomServerTest extends Scope
|
|||
use ProjectCustom;
|
||||
use SideServer;
|
||||
|
||||
public function testListCollections()
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$test1 = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'name' => 'Test 1',
|
||||
'collectionId' => 'first',
|
||||
'read' => ['role:all'],
|
||||
'write' => ['role:all'],
|
||||
]);
|
||||
|
||||
$test2 = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'name' => 'Test 2',
|
||||
'collectionId' => 'second',
|
||||
'read' => ['role:all'],
|
||||
'write' => ['role:all'],
|
||||
]);
|
||||
|
||||
$collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(2, $collections['body']['sum']);
|
||||
$this->assertEquals($test1['body']['$id'], $collections['body']['collections'][0]['$id']);
|
||||
$this->assertEquals($test2['body']['$id'], $collections['body']['collections'][1]['$id']);
|
||||
|
||||
/**
|
||||
* Test for Order
|
||||
*/
|
||||
$base = array_reverse($collections['body']['collections']);
|
||||
$collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'orderType' => 'DESC'
|
||||
]);
|
||||
|
||||
$this->assertEquals(2, $collections['body']['sum']);
|
||||
$this->assertEquals($base[0]['$id'], $collections['body']['collections'][0]['$id']);
|
||||
$this->assertEquals($base[1]['$id'], $collections['body']['collections'][1]['$id']);
|
||||
|
||||
/**
|
||||
* Test for After
|
||||
*/
|
||||
$base = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'after' => $base['body']['collections'][0]['$id']
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $collections['body']['collections']);
|
||||
$this->assertEquals($base['body']['collections'][1]['$id'], $collections['body']['collections'][0]['$id']);
|
||||
|
||||
$collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'after' => $base['body']['collections'][1]['$id']
|
||||
]);
|
||||
|
||||
$this->assertCount(0, $collections['body']['collections']);
|
||||
$this->assertEmpty($collections['body']['collections']);
|
||||
}
|
||||
|
||||
public function testDeleteCollection()
|
||||
{
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue