tests: add graphql tests
This commit is contained in:
parent
7020c85f78
commit
0b9526fc50
2 changed files with 84 additions and 13 deletions
|
@ -106,9 +106,12 @@ trait Base
|
|||
|
||||
// Teams
|
||||
public static string $GET_TEAM = 'get_team';
|
||||
public static string $GET_TEAM_PREFERENCES = 'get_team_preferences';
|
||||
public static string $GET_TEAMS = 'list_teams';
|
||||
public static string $CREATE_TEAM = 'create_team';
|
||||
public static string $UPDATE_TEAM = 'update_team';
|
||||
public static string $UPDATE_TEAM_NAME = 'update_team_name';
|
||||
public static string $UPDATE_TEAM_PREFERENCES = 'update_team_preferences';
|
||||
|
||||
public static string $DELETE_TEAM = 'delete_team';
|
||||
public static string $GET_TEAM_MEMBERSHIP = 'get_team_membership';
|
||||
public static string $GET_TEAM_MEMBERSHIPS = 'list_team_memberships';
|
||||
|
@ -1180,10 +1183,16 @@ trait Base
|
|||
}';
|
||||
case self::$GET_TEAM:
|
||||
return 'query getTeam($teamId: String!){
|
||||
teamsGet(teamId: $teamId) {
|
||||
_id
|
||||
name
|
||||
total
|
||||
teamsGet(teamId: $teamId) {
|
||||
_id
|
||||
name
|
||||
total
|
||||
}
|
||||
}';
|
||||
case self::$GET_TEAM_PREFERENCES:
|
||||
return 'query getTeamPreferences($teamId: String!) {
|
||||
teamsGetPrefs(teamId: $teamId) {
|
||||
data
|
||||
}
|
||||
}';
|
||||
case self::$GET_TEAMS:
|
||||
|
@ -1204,12 +1213,18 @@ trait Base
|
|||
total
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_TEAM:
|
||||
return 'mutation updateTeam($teamId: String!, $name: String!){
|
||||
teamsUpdate(teamId: $teamId, name : $name) {
|
||||
_id
|
||||
name
|
||||
total
|
||||
case self::$UPDATE_TEAM_NAME:
|
||||
return 'mutation updateTeamName($teamId: String!, $name: String!){
|
||||
teamsUpdateName(teamId: $teamId, name : $name) {
|
||||
_id
|
||||
name
|
||||
total
|
||||
}
|
||||
}';
|
||||
case self::$UPDATE_TEAM_PREFERENCES:
|
||||
return 'mutation updateTeamPrefs($teamId: String!, $prefs: Assoc!){
|
||||
teamsUpdatePrefs(teamId: $teamId, prefs: $prefs) {
|
||||
data
|
||||
}
|
||||
}';
|
||||
case self::$DELETE_TEAM:
|
||||
|
|
|
@ -111,6 +111,62 @@ class TeamsServerTest extends Scope
|
|||
$this->assertArrayNotHasKey('errors', $team['body']);
|
||||
$team = $team['body']['data']['teamsGet'];
|
||||
$this->assertIsArray($team);
|
||||
|
||||
return $team;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetTeam
|
||||
*/
|
||||
public function testUpdateTeamPrefs($team)
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$query = $this->getQuery(self::$UPDATE_TEAM_PREFERENCES);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
'teamId' => $team['_id'],
|
||||
'prefs' => [
|
||||
'key' => 'value'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$prefs = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), $graphQLPayload);
|
||||
|
||||
$this->assertIsArray($prefs['body']['data']);
|
||||
$this->assertArrayNotHasKey('errors', $prefs['body']);
|
||||
$this->assertIsArray($prefs['body']['data']['teamsUpdatePrefs']);
|
||||
$this->assertEquals('{"key":"value"}', $prefs['body']['data']['teamsUpdatePrefs']['data']);
|
||||
|
||||
return $team;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testUpdateTeamPrefs
|
||||
*/
|
||||
public function testGetTeamPreferences($team)
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$query = $this->getQuery(self::$GET_TEAM_PREFERENCES);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
'teamId' => $team['_id'],
|
||||
]
|
||||
];
|
||||
|
||||
$prefs = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), $graphQLPayload);
|
||||
|
||||
$this->assertIsArray($prefs['body']['data']);
|
||||
$this->assertArrayNotHasKey('errors', $prefs['body']);
|
||||
$this->assertIsArray($prefs['body']['data']['teamsGetPrefs']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +224,7 @@ class TeamsServerTest extends Scope
|
|||
public function testUpdateTeam($team)
|
||||
{
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$query = $this->getQuery(self::$UPDATE_TEAM);
|
||||
$query = $this->getQuery(self::$UPDATE_TEAM_NAME);
|
||||
$graphQLPayload = [
|
||||
'query' => $query,
|
||||
'variables' => [
|
||||
|
@ -184,7 +240,7 @@ class TeamsServerTest extends Scope
|
|||
|
||||
$this->assertIsArray($team['body']['data']);
|
||||
$this->assertArrayNotHasKey('errors', $team['body']);
|
||||
$team = $team['body']['data']['teamsUpdate'];
|
||||
$team = $team['body']['data']['teamsUpdateName'];
|
||||
$this->assertEquals('New Name', $team['name']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue