mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
test(vcs): express the fake's refresh behaviour as a match
The unit suite has no other switch statement, and match drops the two repeated returns along with the fallthrough to the default tokens.
This commit is contained in:
1 parent
045078941c
commit
7ad4eea88b
1 file changed
+11
-20
@@ -381,26 +381,17 @@ final class InstallationTokensTest extends TestCase
|
||||
|
||||
// GitHub states a refused token in a 200 body; GitLab and Gitea answer 400.
|
||||
// A request that never completed states nothing at all.
|
||||
switch ($this->refresh) {
|
||||
case 'refused':
|
||||
$this->tokens = ['error' => 'bad_refresh_token'];
|
||||
|
||||
return $this->tokens;
|
||||
case 'invalidGrant':
|
||||
throw new OAuth2Exception('{"error":"invalid_grant"}', 400);
|
||||
case 'empty':
|
||||
$this->tokens = [];
|
||||
|
||||
return $this->tokens;
|
||||
case 'throw':
|
||||
throw new \RuntimeException('connection timed out');
|
||||
}
|
||||
|
||||
$this->tokens = [
|
||||
'access_token' => 'fresh-token',
|
||||
'refresh_token' => 'fresh-refresh',
|
||||
'expires_in' => 3600,
|
||||
];
|
||||
$this->tokens = match ($this->refresh) {
|
||||
'refused' => ['error' => 'bad_refresh_token'],
|
||||
'invalidGrant' => throw new OAuth2Exception('{"error":"invalid_grant"}', 400),
|
||||
'empty' => [],
|
||||
'throw' => throw new \RuntimeException('connection timed out'),
|
||||
default => [
|
||||
'access_token' => 'fresh-token',
|
||||
'refresh_token' => 'fresh-refresh',
|
||||
'expires_in' => 3600,
|
||||
],
|
||||
};
|
||||
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user