From bd7395cb446414f131c62d96cf623ddc8173771f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 24 Aug 2022 09:22:13 +0000 Subject: [PATCH] Bug fixing, upgrade tests to new syntax --- app/controllers/api/databases.php | 2 +- composer.lock | 2 +- .../Validator/Queries/TeamMemberships.php | 2 +- tests/e2e/Services/Account/AccountBase.php | 7 +++---- tests/e2e/Services/Databases/DatabasesBase.php | 8 ++++---- .../Functions/FunctionsCustomClientTest.php | 5 ++--- .../Services/Storage/StorageCustomServerTest.php | 2 +- tests/e2e/Services/Teams/TeamsBase.php | 15 ++++++--------- tests/e2e/Services/Teams/TeamsBaseClient.php | 2 +- 9 files changed, 20 insertions(+), 25 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index fa78d003f8..5b64db341e 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2042,7 +2042,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') // Validate queries $validator = new Documents($collection->getAttribute('attributes'), $collection->getAttribute('indexes')); - $valid = $validator->isValid($collection->getRead()); + $valid = $validator->isValid($queries); if (!$valid) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $validator->getDescription()); } diff --git a/composer.lock b/composer.lock index f31e5efe52..b9176fe53e 100644 --- a/composer.lock +++ b/composer.lock @@ -2874,7 +2874,7 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/feat-change-default-functionID" + "source": "https://github.com/appwrite/sdk-generator/tree/master" }, "time": "2022-08-19T10:03:22+00:00" }, diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php b/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php index eff5016e6c..5a29e3b63e 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php @@ -20,6 +20,6 @@ class TeamMemberships extends Base */ public function __construct() { - parent::__construct('teamMemberships', self::ALLOWED_ATTRIBUTES); + parent::__construct('memberships', self::ALLOWED_ATTRIBUTES); } } diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index 1b287357b8..e5f20f1d80 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -390,7 +390,7 @@ trait AccountBase 'x-appwrite-project' => $this->getProject()['$id'], 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ]), [ - 'limit' => 1 + 'queries' => [ 'limit(1)' ], ]); $this->assertEquals($responseLimit['headers']['status-code'], 200); @@ -407,7 +407,7 @@ trait AccountBase 'x-appwrite-project' => $this->getProject()['$id'], 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ]), [ - 'offset' => 1 + 'queries' => [ 'offset(1)' ], ]); $this->assertEquals($responseOffset['headers']['status-code'], 200); @@ -424,8 +424,7 @@ trait AccountBase 'x-appwrite-project' => $this->getProject()['$id'], 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ]), [ - 'limit' => 1, - 'offset' => 1 + 'queries' => [ 'limit(1)', 'offset(1)' ], ]); $this->assertEquals($responseLimitOffset['headers']['status-code'], 200); diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 4df1c71760..21ddede753 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -986,10 +986,11 @@ trait DatabasesBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'orderAttributes' => ['releaseYear'], - 'orderTypes' => ['ASC'], + 'queries' => [ 'orderAsc("releaseYear")' ], ]); + \var_dump($documents); + $this->assertEquals(200, $documents['headers']['status-code']); $this->assertEquals(1944, $documents['body']['documents'][0]['releaseYear']); $this->assertEquals(2017, $documents['body']['documents'][1]['releaseYear']); @@ -1007,8 +1008,7 @@ trait DatabasesBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'orderAttributes' => ['releaseYear'], - 'orderTypes' => ['DESC'], + 'queries' => [ 'orderDesc("releaseYear")' ], ]); $this->assertEquals(200, $documents['headers']['status-code']); diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index cfc1b3e64a..b35b5cfab8 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -293,7 +293,7 @@ class FunctionsCustomClientTest extends Scope 'x-appwrite-project' => $projectId, 'x-appwrite-key' => $apikey, ], [ - 'cursor' => $base['body']['executions'][0]['$id'] + 'queries' => [ 'cursorAfter("' . $base['body']['executions'][0]['$id'] . '")' ], ]); $this->assertCount(1, $executions['body']['executions']); @@ -304,8 +304,7 @@ class FunctionsCustomClientTest extends Scope 'x-appwrite-project' => $projectId, 'x-appwrite-key' => $apikey, ], [ - 'cursor' => $base['body']['executions'][1]['$id'], - 'cursorDirection' => Database::CURSOR_BEFORE + 'queries' => [ 'cursorBefore("' . $base['body']['executions'][1]['$id'] . '")' ], ]); // Cleanup : Delete function diff --git a/tests/e2e/Services/Storage/StorageCustomServerTest.php b/tests/e2e/Services/Storage/StorageCustomServerTest.php index 13130f1ea1..226df031bf 100644 --- a/tests/e2e/Services/Storage/StorageCustomServerTest.php +++ b/tests/e2e/Services/Storage/StorageCustomServerTest.php @@ -98,7 +98,7 @@ class StorageCustomServerTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'cursor' => $response['body']['buckets'][0]['$id'], + 'queries' => [ 'cursorAfter("' . $response['body']['buckets'][0]['$id'] . '")' ], ]); $this->assertEquals(200, $response['headers']['status-code']); diff --git a/tests/e2e/Services/Teams/TeamsBase.php b/tests/e2e/Services/Teams/TeamsBase.php index 2404ca3243..7f2c4244d3 100644 --- a/tests/e2e/Services/Teams/TeamsBase.php +++ b/tests/e2e/Services/Teams/TeamsBase.php @@ -128,7 +128,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'limit' => 2, + 'queries' => [ 'limit(2)' ], ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -140,7 +140,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'offset' => 1, + 'queries' => [ 'offset(1)' ], ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -191,7 +191,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'limit' => 2, + 'queries' => [ 'limit(2)' ], ]); $this->assertEquals(200, $teams['headers']['status-code']); @@ -203,8 +203,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'limit' => 1, - 'cursor' => $teams['body']['teams'][0]['$id'] + 'queries' => [ 'limit(1)', 'cursorAfter("' . $teams['body']['teams'][0]['$id'] . '")' ], ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -217,9 +216,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'limit' => 1, - 'cursor' => $teams['body']['teams'][1]['$id'], - 'cursorDirection' => Database::CURSOR_BEFORE + 'queries' => [ 'limit(1)', 'cursorBefore("' . $teams['body']['teams'][1]['$id'] . '")' ], ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -235,7 +232,7 @@ trait TeamsBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'cursor' => 'unknown' + 'queries' => [ 'cursorAfter("unknown")' ], ]); $this->assertEquals(400, $response['headers']['status-code']); diff --git a/tests/e2e/Services/Teams/TeamsBaseClient.php b/tests/e2e/Services/Teams/TeamsBaseClient.php index e07e9fbb18..3a1921105b 100644 --- a/tests/e2e/Services/Teams/TeamsBaseClient.php +++ b/tests/e2e/Services/Teams/TeamsBaseClient.php @@ -209,7 +209,7 @@ trait TeamsBaseClient 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'cursor' => $memberships['body']['memberships'][0]['$id'] + 'queries' => [ 'cursorAfter("' . $memberships['body']['memberships'][0]['$id'] . '")' ] ]); $this->assertEquals(200, $response['headers']['status-code']);