From bdd65ed4480bc4ae7a51c4087764f99fbeb7ac99 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 1 Jul 2022 12:02:59 +1200 Subject: [PATCH] User test updates for 0.15 --- tests/e2e/Services/GraphQL/GraphQLBase.php | 7 +-- .../e2e/Services/GraphQL/GraphQLUsersTest.php | 46 +++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tests/e2e/Services/GraphQL/GraphQLBase.php b/tests/e2e/Services/GraphQL/GraphQLBase.php index e237e406f7..e5fa39485d 100644 --- a/tests/e2e/Services/GraphQL/GraphQLBase.php +++ b/tests/e2e/Services/GraphQL/GraphQLBase.php @@ -84,7 +84,7 @@ trait GraphQLBase public static string $UPDATE_USER_NAME = 'update_user_name'; public static string $UPDATE_USER_EMAIL = 'update_user_email'; public static string $UPDATE_USER_EMAIL_VERIFICATION = 'update_email_verification'; - public static string $UPDATE_USER_PHONE_VERIFICATION = 'update_email_verification'; + public static string $UPDATE_USER_PHONE_VERIFICATION = 'update_phone_verification'; public static string $UPDATE_USER_PASSWORD = 'update_user_password'; public static string $UPDATE_USER_PHONE = 'update_user_phone'; public static string $UPDATE_USER_PREFS = 'update_user_prefs'; @@ -488,6 +488,7 @@ trait GraphQLBase case self::$UPDATE_USER_PHONE_VERIFICATION: return 'mutation updateUserPhoneVerification($userId: String!, $phoneVerification: Boolean!){ usersUpdatePhoneVerification(userId: $userId, phoneVerification: $phoneVerification) { + _id name email } @@ -725,8 +726,8 @@ trait GraphQLBase } }'; case self::$UPDATE_PHONE_VERIFICATION: - return 'mutation confirmPhoneVerification($userId: String!, $secret: String!) { - accountUpdatePhoneVerification(userId: $userId, secret: $secret) { + return 'mutation confirmPhoneVerification($userId: String!, $phoneVerification: Boolean!) { + accountUpdatePhoneVerification(userId: $userId, phoneVerification: $phoneVerification) { userId secret expire diff --git a/tests/e2e/Services/GraphQL/GraphQLUsersTest.php b/tests/e2e/Services/GraphQL/GraphQLUsersTest.php index 1837050ffb..5bd6c28dd5 100644 --- a/tests/e2e/Services/GraphQL/GraphQLUsersTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLUsersTest.php @@ -214,31 +214,31 @@ class GraphQLUsersTest extends Scope $this->assertIsArray($user['body']['data']); $this->assertArrayNotHasKey('errors', $user['body']); - $this->assertIsArray($user['body']['data']['usersUpdateVerification']); + $this->assertIsArray($user['body']['data']['usersUpdateEmailVerification']); } -// public function testUpdateUserPhoneVerification() -// { -// $projectId = $this->getProject()['$id']; -// $query = $this->getQuery(self::$UPDATE_USER_PHONE_VERIFICATION); -// $graphQLPayload = [ -// 'query' => $query, -// 'variables' => [ -// 'userId' => $this->getUser()['$id'], -// 'phoneVerification' => true, -// ] -// ]; -// -// $user = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ -// 'content-type' => 'application/json', -// 'x-appwrite-project' => $projectId, -// ], $this->getHeaders()), $graphQLPayload); -// -// $this->assertIsArray($user['body']['data']); -// $this->assertArrayNotHasKey('errors', $user['body']); -// $this->assertIsArray($user['body']['data']['usersUpdatePhoneVerification']); -// $this->assertEquals($this->getUser()['$id'], $user['body']['data']['usersUpdatePhoneVerification']['_id']); -// } + public function testUpdateUserPhoneVerification() + { + $projectId = $this->getProject()['$id']; + $query = $this->getQuery(self::$UPDATE_USER_PHONE_VERIFICATION); + $graphQLPayload = [ + 'query' => $query, + 'variables' => [ + 'userId' => $this->getUser()['$id'], + 'phoneVerification' => true, + ] + ]; + + $user = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders()), $graphQLPayload); + + $this->assertIsArray($user['body']['data']); + $this->assertArrayNotHasKey('errors', $user['body']); + $this->assertIsArray($user['body']['data']['usersUpdatePhoneVerification']); + $this->assertEquals($this->getUser()['$id'], $user['body']['data']['usersUpdatePhoneVerification']['_id']); + } public function testUpdateUserName() {