WIP server test updates

This commit is contained in:
Jake Barnby
2022-05-04 21:19:28 +12:00
parent 1055a00090
commit d94d5d53bf
2 changed files with 18 additions and 18 deletions
+10 -10
View File
@@ -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 = '';
@@ -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']);