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 ;
@@ -103,10 +104,12 @@ function (RequestInterface $request) {
103104 $ this ->assertEquals ($ this ->testJWT , $ customCache ->getTokenWithContext ($ tokenRequestContext )->getToken ());
104105
105106 // hydrate another cache for follow-up request
106- $ 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 );
107110 $ accessTokenProvider = GraphPhpLeagueAccessTokenProvider::createWithCache (
108111 $ newCache ,
109- $ tokenRequestContext ,
112+ $ newTokenRequestContext ,
110113 $ scopes
111114 );
112115 $ client = GraphServiceClient::createWithRequestAdapter (
@@ -120,6 +123,7 @@ function (RequestInterface $request) {
120123
121124 $ me = $ client ->me ()->get ()->wait ();
122125 // cache is populated
123- $ this ->assertInstanceOf (AccessToken::class, $ newCache ->getTokenWithContext ($ tokenRequestContext ));
126+ $ this ->assertInstanceOf (AccessToken::class, $ newCache ->getTokenWithContext ($ newTokenRequestContext ));
127+ $ this ->assertEquals ($ this ->testJWT , $ newCache ->getTokenWithContext ($ newTokenRequestContext )->getToken ());
124128 }
125129}
0 commit comments