diff --git a/tests/e2e/Services/GraphQL/GraphQLAccountTest.php b/tests/e2e/Services/GraphQL/GraphQLAccountTest.php index 52117614da..573ad839d8 100644 --- a/tests/e2e/Services/GraphQL/GraphQLAccountTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLAccountTest.php @@ -114,31 +114,30 @@ class GraphQLAccountTest extends Scope return $token['body']['data']['accountCreateVerification']; } -// public function testCreatePhoneVerification(): array -// { -// $projectId = $this->getProject()['$id']; -// $query = $this->getQuery(self::$CREATE_PHONE_VERIFICATION); -// $graphQLPayload = [ -// 'query' => $query, -// 'variables' => [ -// 'phone' => '+123456789', -// 'url' => 'https://example.com/verification' -// ], -// ]; -// -// $token = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ -// 'content-type' => 'application/json', -// 'x-appwrite-project' => $projectId, -// ], $this->getHeaders()), $graphQLPayload); -// -// \var_dump($token); -// -// $this->assertArrayNotHasKey('errors', $token['body']); -// $this->assertIsArray($token['body']['data']); -// $this->assertIsArray($token['body']['data']['accountCreatePhoneVerification']); -// -// return $token['body']['data']['accountCreatePhoneVerification']; -// } + /** + * @depends testUpdateAccountPhone + * @return array + * @throws \Exception + */ + public function testCreatePhoneVerification(): array + { + $projectId = $this->getProject()['$id']; + $query = $this->getQuery(self::$CREATE_PHONE_VERIFICATION); + $graphQLPayload = [ + 'query' => $query, + ]; + + $token = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders()), $graphQLPayload); + + $this->assertArrayNotHasKey('errors', $token['body']); + $this->assertIsArray($token['body']['data']); + $this->assertIsArray($token['body']['data']['accountCreatePhoneVerification']); + + return $token['body']['data']['accountCreatePhoneVerification']; + } public function testCreatePasswordRecovery(): array { @@ -367,7 +366,7 @@ class GraphQLAccountTest extends Scope 'query' => $query, 'variables' => [ 'oldPassword' => 'password', - 'password' => 'newpassword', + 'password' => 'password', ] ]; @@ -383,32 +382,30 @@ class GraphQLAccountTest extends Scope return $account; } -// public function testUpdateAccountPhone(): array -// { -// $projectId = $this->getProject()['$id']; -// $query = $this->getQuery(self::$UPDATE_ACCOUNT_PHONE); -// $graphQLPayload = [ -// 'query' => $query, -// 'variables' => [ -// 'phone' => '+123456789', -// 'password' => 'password', -// ] -// ]; -// -// $account = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ -// 'content-type' => 'application/json', -// 'x-appwrite-project' => $projectId, -// ], $this->getHeaders()), $graphQLPayload); -// -// \var_dump($account); -// -// $this->assertArrayNotHasKey('errors', $account['body']); -// $this->assertIsArray($account['body']['data']); -// $this->assertIsArray($account['body']['data']['accountUpdatePhone']); -// $this->assertEquals('+123456789', $account['body']['data']['accountUpdatePhone']['phone']); -// -// return $account; -// } + public function testUpdateAccountPhone(): array + { + $projectId = $this->getProject()['$id']; + $query = $this->getQuery(self::$UPDATE_ACCOUNT_PHONE); + $graphQLPayload = [ + 'query' => $query, + 'variables' => [ + 'number' => '+123456789', + 'password' => 'password', + ] + ]; + + $account = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders()), $graphQLPayload); + + $this->assertArrayNotHasKey('errors', $account['body']); + $this->assertIsArray($account['body']['data']); + $this->assertIsArray($account['body']['data']['accountUpdatePhone']); + $this->assertEquals('+123456789', $account['body']['data']['accountUpdatePhone']['phone']); + + return $account; + } public function testUpdateAccountStatus(): array { diff --git a/tests/e2e/Services/GraphQL/GraphQLBase.php b/tests/e2e/Services/GraphQL/GraphQLBase.php index 4b35192dcf..e237e406f7 100644 --- a/tests/e2e/Services/GraphQL/GraphQLBase.php +++ b/tests/e2e/Services/GraphQL/GraphQLBase.php @@ -480,7 +480,7 @@ trait GraphQLBase }'; case self::$UPDATE_USER_EMAIL_VERIFICATION: return 'mutation updateUserEmailVerification($userId: String!, $emailVerification: Boolean!){ - usersUpdateVerification(userId: $userId, emailVerification: $emailVerification) { + usersUpdateEmailVerification(userId: $userId, emailVerification: $emailVerification) { name email } @@ -552,6 +552,7 @@ trait GraphQLBase name status email + phone } }'; case self::$UPDATE_ACCOUNT_EMAIL: @@ -573,12 +574,13 @@ trait GraphQLBase } }'; case self::$UPDATE_ACCOUNT_PHONE: - return 'mutation updateAccountPhone($phone: String!, $password: String!){ - accountUpdatePhone(phone: $phone, password: $password) { + return 'mutation updateAccountPhone($number: Json!, $password: String!){ + accountUpdatePhone(number: $number, password: $password) { _id name status email + phone } }'; case self::$UPDATE_ACCOUNT_PREFS: