fix graphQL test

This commit is contained in:
Prateek Banga
2023-09-20 22:59:47 +05:30
parent 975b444761
commit 2fd7467e2a
3 changed files with 52 additions and 1 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ return [
'sdk' => true,
'docs' => true,
'docsUrl' => 'https://appwrite.io/docs/server/messaging',
'tests' => false,
'tests' => true,
'optional' => true,
'icon' => '/images/services/messaging.png',
]
@@ -123,6 +123,28 @@ class AccountTest extends Scope
public function testCreatePhoneVerification(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$CREATE_PROVIDER);
$graphQLPayload = [
'query' => $query,
'variables' => [
'providerId' => 'unique()',
'name' => 'Mock',
'provider' => 'mock',
'type' => 'sms',
'credentials' => [
'username' => 'username',
'password' => 'password',
],
'default' => true,
],
];
$this->client->call(Client::METHOD_POST, '/graphql', [
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
'x-appwrite-key' => $this->getProject()['apiKey'],
], $graphQLPayload);
$query = $this->getQuery(self::$CREATE_PHONE_VERIFICATION);
$graphQLPayload = [
'query' => $query,
+29
View File
@@ -296,6 +296,8 @@ trait Base
}
';
public static string $CREATE_PROVIDER = 'create_provider';
public function getQuery(string $name): string
{
switch ($name) {
@@ -1929,6 +1931,33 @@ trait Base
}
}
}' . PHP_EOL . self::$FRAGMENT_ATTRIBUTES;
case self::$CREATE_PROVIDER:
return 'mutation CreateGeneralProvider(
$providerId: String!,
$provider: String!,
$name: String!,
$type: String!,
$default: Boolean,
$enabled: Boolean,
$credentials: Json!
) {
messagingCreateGeneralProvider(
providerId: $providerId,
provider: $provider,
name: $name,
type: $type,
default: $default,
enabled: $enabled,
credentials: $credentials
) {
_id
name
provider
type
default
enabled
}
}';
}
throw new \InvalidArgumentException('Invalid query type');