Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,41 @@ private function add_authenticate_filter(): void {
* @return array{code: ?string, error: ?string} The mutation payload.
*/
private function generate_authorization_code( array $input ): array {
$result = graphql(
array(
'query' => '
mutation Generate( $username: String, $email: String, $password: String ) {
generateAuthorizationCode( input: { username: $username, email: $email, password: $password } ) {
code
error
}
}
',
'variables' => array(
'username' => $input['username'] ?? null,
'email' => $input['email'] ?? null,
'password' => $input['password'] ?? null,
),
)
// Deprecations raised inside WPGraphQL aren't Faust's to fix, and failing
// mid-request leaves WPGraphQL's request state set for later tests.
$previous_handler = set_error_handler(
static function ( ...$args ) use ( &$previous_handler ) {
if ( 0 === strpos( $args[2], WP_TEST_PLUGINS_DIR . '/wp-graphql/' ) ) {
return true;
}

return $previous_handler ? $previous_handler( ...$args ) : false;
},
E_DEPRECATED
);

try {
$result = graphql(
array(
'query' => '
mutation Generate( $username: String, $email: String, $password: String ) {
generateAuthorizationCode( input: { username: $username, email: $email, password: $password } ) {
code
error
}
}
',
'variables' => array(
'username' => $input['username'] ?? null,
'email' => $input['email'] ?? null,
'password' => $input['password'] ?? null,
),
)
);
} finally {
restore_error_handler();
}

$this->assertArrayNotHasKey( 'errors', $result, 'The mutation should not raise GraphQL errors.' );

return $result['data']['generateAuthorizationCode'];
Expand Down
Loading