@@ -15,14 +15,12 @@ class OAuth2Test extends TestCase
1515{
1616 public function testGetAuthenticationUrl (): void
1717 {
18- $ client = new GuzzleClient ();
19-
20- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
18+ $ auth = new OAuth2 (new HttpClient (), '123 ' , '456 ' );
2119 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=123&response_type=code ' , $ auth ->getAuthenticationUrl ());
2220 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=123&response_type=pin ' , $ auth ->getAuthenticationUrl ('pin ' ));
2321 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=123&response_type=code&state=draft ' , $ auth ->getAuthenticationUrl ('code ' , 'draft ' ));
2422
25- $ auth = new OAuth2 (new HttpClient ([], $ client ), '456 ' , '789 ' );
23+ $ auth = new OAuth2 (new HttpClient (), '456 ' , '789 ' );
2624 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=456&response_type=pin ' , $ auth ->getAuthenticationUrl ('pin ' ));
2725 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=456&response_type=code ' , $ auth ->getAuthenticationUrl ());
2826 $ this ->assertSame ('https://api.imgur.com/oauth2/authorize?client_id=456&response_type=code&state=draft ' , $ auth ->getAuthenticationUrl ('code ' , 'draft ' ));
@@ -39,7 +37,7 @@ public function testRequestAccessTokenBadStatusCode(): void
3937 $ handler = HandlerStack::create ($ mock );
4038 $ client = new GuzzleClient (['handler ' => $ handler ]);
4139
42- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
40+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
4341 $ auth ->requestAccessToken ('code ' , null );
4442 }
4543
@@ -51,7 +49,7 @@ public function testRequestAccessTokenWithCode(): void
5149 $ handler = HandlerStack::create ($ mock );
5250 $ client = new GuzzleClient (['handler ' => $ handler ]);
5351
54- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
52+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
5553 $ result = $ auth ->requestAccessToken ('code ' , null );
5654
5755 $ this ->assertArrayHasKey ('access_token ' , $ result );
@@ -68,7 +66,7 @@ public function testRequestAccessTokenWithPin(): void
6866 $ handler = HandlerStack::create ($ mock );
6967 $ client = new GuzzleClient (['handler ' => $ handler ]);
7068
71- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
69+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
7270 $ result = $ auth ->requestAccessToken ('code ' , 'pin ' );
7371
7472 $ this ->assertArrayHasKey ('access_token ' , $ result );
@@ -88,7 +86,7 @@ public function testRefreshTokenBadStatusCode(): void
8886 $ handler = HandlerStack::create ($ mock );
8987 $ client = new GuzzleClient (['handler ' => $ handler ]);
9088
91- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
89+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
9290 $ auth ->refreshToken ();
9391 }
9492
@@ -100,7 +98,7 @@ public function testRefreshToken(): void
10098 $ handler = HandlerStack::create ($ mock );
10199 $ client = new GuzzleClient (['handler ' => $ handler ]);
102100
103- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
101+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
104102 $ result = $ auth ->refreshToken ();
105103
106104 $ this ->assertArrayHasKey ('access_token ' , $ result );
@@ -113,7 +111,7 @@ public function testSetAccessTokenNull(): void
113111 $ this ->expectExceptionMessage ('Token is not a valid json string. ' );
114112
115113 $ client = new GuzzleClient ();
116- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
114+ $ auth = new OAuth2 (new HttpClient (), '123 ' , '456 ' );
117115 $ auth ->setAccessToken (null );
118116 }
119117
@@ -123,14 +121,14 @@ public function testSetAccessTokenEmpty(): void
123121 $ this ->expectExceptionMessage ('Access token could not be retrieved from the decoded json response. ' );
124122
125123 $ client = new GuzzleClient ();
126- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
124+ $ auth = new OAuth2 (new HttpClient (), '123 ' , '456 ' );
127125 $ auth ->setAccessToken (['data ' ]);
128126 }
129127
130128 public function testCheckAccessTokenExpiredFromScratch (): void
131129 {
132130 $ client = new GuzzleClient ();
133- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
131+ $ auth = new OAuth2 (new HttpClient (), '123 ' , '456 ' );
134132 $ this ->assertTrue ($ auth ->checkAccessTokenExpired ());
135133 }
136134
@@ -142,7 +140,7 @@ public function testCheckAccessTokenExpired(): void
142140 $ handler = HandlerStack::create ($ mock );
143141 $ client = new GuzzleClient (['handler ' => $ handler ]);
144142
145- $ auth = new OAuth2 (new HttpClient ([], $ client ), '123 ' , '456 ' );
143+ $ auth = new OAuth2 (new HttpClient ([], $ client, $ handler ), '123 ' , '456 ' );
146144 $ auth ->requestAccessToken ('code ' , null );
147145
148146 $ this ->assertFalse ($ auth ->checkAccessTokenExpired ());
@@ -157,7 +155,7 @@ public function testAuthenticatedRequest(): void
157155 $ handler = HandlerStack::create ($ mock );
158156 $ client = new GuzzleClient (['handler ' => $ handler ]);
159157
160- $ httpClient = new HttpClient ([], $ client );
158+ $ httpClient = new HttpClient ([], $ client, $ handler , $ handler );
161159
162160 $ auth = new OAuth2 ($ httpClient , '123 ' , '456 ' );
163161 $ auth ->requestAccessToken ('code ' , null );
0 commit comments