From d94d5d53bf5ac483cbad50416ec321a6d170e461 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 4 May 2022 21:19:28 +1200 Subject: [PATCH] WIP server test updates --- tests/e2e/Services/GraphQL/GraphQLBase.php | 20 +++++++++---------- .../Services/GraphQL/GraphQLServerTest.php | 16 +++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/e2e/Services/GraphQL/GraphQLBase.php b/tests/e2e/Services/GraphQL/GraphQLBase.php index 5c824da2f7..5c4bb28532 100644 --- a/tests/e2e/Services/GraphQL/GraphQLBase.php +++ b/tests/e2e/Services/GraphQL/GraphQLBase.php @@ -371,7 +371,7 @@ trait GraphQLBase }'; case self::$DELETE_USER : return 'mutation deleteUser($userId: String!) { - usersDeleteUser(userId : $userId) + usersDelete(userId: $userId) }'; case self::$LIST_COUNTRIES: return 'query listCountries { @@ -745,8 +745,8 @@ trait GraphQLBase ], $gqlPayload); $errorMessage = 'User (role: guest) missing scope (collections.write)'; - $this->assertEquals($actors['headers']['status-code'], 401); - $this->assertEquals($actors['body']['errors'][0]['message'], $errorMessage); + $this->assertEquals(401, $actors['headers']['status-code']); + $this->assertEquals($errorMessage, $actors['body']['errors'][0]['message']); $this->assertIsArray($actors['body']['data']); $this->assertNull($actors['body']['data']['databaseCreateCollection']); @@ -759,7 +759,7 @@ trait GraphQLBase 'x-appwrite-key' => $key ], $gqlPayload); - $this->assertEquals($actors['headers']['status-code'], 201); + $this->assertEquals(201, $actors['headers']['status-code']); $this->assertNull($actors['body']['errors']); $this->assertIsArray($actors['body']['data']); @@ -781,7 +781,7 @@ trait GraphQLBase * @depends testCreateCollection * @throws \Exception */ - public function testCreateStringAttribute(array $data) + public function testCreateStringAttribute(array $data): void { $projectId = $this->getProject()['$id']; $key = $data['key']; @@ -815,7 +815,7 @@ trait GraphQLBase * @depends testCreateCollection * @throws \Exception */ - public function testCreateIntegerAttribute(array $data) + public function testCreateIntegerAttribute(array $data): void { $projectId = $this->getProject()['$id']; $key = $data['key']; @@ -850,7 +850,7 @@ trait GraphQLBase * @depends testCreateCollection * @throws \Exception */ - public function testCreateBooleanAttribute(array $data) + public function testCreateBooleanAttribute(array $data): void { $projectId = $this->getProject()['$id']; $key = $data['key']; @@ -883,7 +883,7 @@ trait GraphQLBase * @depends testCreateCollection * @throws \Exception */ - public function testCreateFloatAttribute(array $data) + public function testCreateFloatAttribute(array $data): void { $projectId = $this->getProject()['$id']; $key = $data['key']; @@ -923,7 +923,7 @@ trait GraphQLBase * @depends testCreateFloatAttribute * @throws \Exception */ - public function testCreateDocumentREST(array $data) + public function testCreateDocumentREST(array $data): void { $projectId = $this->getProject()['$id']; $key = $data['key']; @@ -964,7 +964,7 @@ trait GraphQLBase * @depends testCreateFloatAttribute * @throws \Exception */ - public function testCreateDocumentGQL(array $data) + public function testCreateDocumentGQL(array $data): void { $projectId = $this->getProject()['$id']; $key = ''; diff --git a/tests/e2e/Services/GraphQL/GraphQLServerTest.php b/tests/e2e/Services/GraphQL/GraphQLServerTest.php index 25f2ecc1e0..ea9691d1d3 100644 --- a/tests/e2e/Services/GraphQL/GraphQLServerTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLServerTest.php @@ -103,11 +103,10 @@ class GraphQLServerTest extends Scope $errorMessage = 'User (role: guest) missing scope (users.write)'; $this->assertEquals($errorMessage, $user['body']['errors'][0]['message']); - $this->assertIsArray($user['body']['data']); - $this->assertNull($user['body']['data']['usersCreate']); + $this->assertArrayNotHasKey('data', $user['body']); /** - * Create the user with the reqiured scopes + * Create the user with the required scopes */ $key = $this->getNewKey(['users.write']); $user = $this->client->call(Client::METHOD_POST, '/graphql', array_merge([ @@ -121,15 +120,14 @@ class GraphQLServerTest extends Scope $this->assertIsArray($user['body']['data']['usersCreate']); $data = $user['body']['data']['usersCreate']; - $this->assertArrayHasKey('id', $data); + $this->assertArrayHasKey('_id', $data); $this->assertArrayHasKey('registration', $data); $this->assertEquals($variables['name'], $data['name']); $this->assertEquals($variables['email'], $data['email']); - $this->assertEquals(0, $data['status']); + $this->assertEquals(true, $data['status']); $this->assertEquals(false, $data['emailVerification']); - $this->assertEquals([], $data['prefs']); - return ['userId' => $user['body']['data']['users_create']['id']]; + return ['userId' => $user['body']['data']['usersCreate']['_id']]; } /** @@ -242,8 +240,10 @@ class GraphQLServerTest extends Scope 'x-appwrite-key' => $key ], $graphQLPayload); + //\var_dump($countries); + $errorMessage = 'app.${projectId}@service.localhost (role: application) missing scope (locale.read)'; - $this->assertEquals($countries['headers']['status-code'], 401); + $this->assertEquals( 401, $countries['headers']['status-code']); $this->assertEquals($countries['body']['errors'][0]['message'], $errorMessage); $this->assertIsArray($countries['body']['data']); $this->assertNull($countries['body']['data']['locale_getCountries']);