Skip to content

Commit 7aa0c2b

Browse files
authored
Merge branch 'main' into dependabot/composer/phpstan/phpstan-tw-0.12.90or-tw-1.0.0or-tw-2.0.0
2 parents ab260fa + aaf66fd commit 7aa0c2b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/GraphServiceClientTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use GuzzleHttp\Client;
66
use GuzzleHttp\Handler\MockHandler;
77
use GuzzleHttp\Psr7\Response;
8+
use League\OAuth2\Client\Grant\AuthorizationCode;
89
use League\OAuth2\Client\Token\AccessToken;
910
use Microsoft\Graph\Core\Authentication\GraphPhpLeagueAccessTokenProvider;
1011
use Microsoft\Graph\Core\Authentication\GraphPhpLeagueAuthenticationProvider;
@@ -100,12 +101,15 @@ function (RequestInterface $request) {
100101

101102
// cache is populated
102103
$this->assertInstanceOf(AccessToken::class, $customCache->getTokenWithContext($tokenRequestContext));
104+
$this->assertEquals($this->testJWT, $customCache->getTokenWithContext($tokenRequestContext)->getToken());
103105

104106
// hydrate another cache for follow-up request
105-
$newCache = new InMemoryAccessTokenCache($tokenRequestContext, $customCache->getTokenWithContext($tokenRequestContext));
107+
$previousAccessToken = $customCache->getTokenWithContext($tokenRequestContext);
108+
$newTokenRequestContext = new AuthorizationCodeContext('tenant', 'clientId', 'clientSecret', 'redirectUri', 'code');
109+
$newCache = new InMemoryAccessTokenCache($newTokenRequestContext, $previousAccessToken);
106110
$accessTokenProvider = GraphPhpLeagueAccessTokenProvider::createWithCache(
107111
$newCache,
108-
$tokenRequestContext,
112+
$newTokenRequestContext,
109113
$scopes
110114
);
111115
$client = GraphServiceClient::createWithRequestAdapter(
@@ -119,6 +123,7 @@ function (RequestInterface $request) {
119123

120124
$me = $client->me()->get()->wait();
121125
// cache is populated
122-
$this->assertInstanceOf(AccessToken::class, $customCache->getTokenWithContext($tokenRequestContext));
126+
$this->assertInstanceOf(AccessToken::class, $newCache->getTokenWithContext($newTokenRequestContext));
127+
$this->assertEquals($this->testJWT, $newCache->getTokenWithContext($newTokenRequestContext)->getToken());
123128
}
124129
}

0 commit comments

Comments
 (0)