test(vcs): cover the state a cleared installation is left in

Once the pair is cleared the expiry is null, which the refresh treats as
nothing to do, so the installation comes back untouched and the provider
is not called. GitHub then works from its app credentials. That behaviour
now carries the recovery for installations whose refresh token is gone, so
it should be pinned down rather than inferred.
This commit is contained in:
harsh mahajan committed 2026-07-29 14:47:13 +05:30
1 parent a3b3697938
commit 045078941c
1 file changed
+24
+24
View File
@@ -76,6 +76,30 @@ final class InstallationTokensTest extends TestCase
$this->assertSame(0, $oauth2->refreshCalls);
}
public function testClearedInstallationIsReturnedWithoutCallingTheProvider(): void
{
// The state clear() leaves behind. GitHub works from here on its app credentials, and the
// providers that need the token fail at the adapter with a definite reason.
$installation = new Document([
'$id' => 'installation1',
'personalAccessToken' => '',
'personalRefreshToken' => '',
'personalAccessTokenExpiry' => null,
]);
$db = $this->createMock(Database::class);
$db->method('getAuthorization')->willReturn(new Authorization());
$db->expects($this->never())->method('updateDocument');
$db->expects($this->never())->method('createDocument');
$oauth2 = $this->fakeOAuth2();
$result = (new InstallationTokens())->refresh($installation, $db, $oauth2);
$this->assertSame('', $result->getAttribute('personalAccessToken'));
$this->assertSame(0, $oauth2->refreshCalls);
}
public function testExpiredTokenIsRefreshedAndPersisted(): void
{
$db = $this->createMock(Database::class);