55use GuzzleHttp \Client ;
66use GuzzleHttp \Handler \MockHandler ;
77use GuzzleHttp \Psr7 \Response ;
8+ use League \OAuth2 \Client \Grant \AuthorizationCode ;
89use League \OAuth2 \Client \Token \AccessToken ;
910use Microsoft \Graph \Core \Authentication \GraphPhpLeagueAccessTokenProvider ;
1011use 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