From 06719b172cefdbbd4d15dbfcef2e7387c7c1ae7f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 22:04:57 +1300 Subject: [PATCH] Add listCollection using `search` parameter tests --- .../Database/DatabaseCustomServerTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 659839debe..b770b2b6c3 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -125,6 +125,39 @@ class DatabaseCustomServerTest extends Scope $this->assertCount(0, $collections['body']['collections']); $this->assertEmpty($collections['body']['collections']); + /** + * Test for Search + */ + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'first' + ]); + + $this->assertEquals(1, $collections['body']['sum']); + $this->assertEquals('first', $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()), [ + 'search' => 'Test' + ]); + + $this->assertEquals(2, $collections['body']['sum']); + $this->assertEquals('Test 1', $collections['body']['collections'][0]['name']); + $this->assertEquals('Test 2', $collections['body']['collections'][1]['name']); + + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'Nonexistent' + ]); + + $this->assertEquals(0, $collections['body']['sum']); + /** * Test for FAILURE */