File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ public function __construct(array $options = [])
118118 } elseif (!empty ($ options ['expires ' ])) {
119119 // Some providers supply the seconds until expiration rather than
120120 // the exact timestamp. Take a best guess at which we received.
121- $ expires = $ options ['expires ' ];
121+ $ expires = ( int ) $ options ['expires ' ];
122122
123123 if (!$ this ->isExpirationTimestamp ($ expires )) {
124124 $ expires += $ this ->getTimeNow ();
Original file line number Diff line number Diff line change @@ -222,6 +222,32 @@ public function testInvalidExpiresIn()
222222 self ::tearDownForBackwardsCompatibility ();
223223 }
224224
225+ public function testInvalidExpiresWhenExpiresDoesNotCastToInteger ()
226+ {
227+ $ options = [
228+ 'access_token ' => 'access_token ' ,
229+ 'expires ' => 'TEXT ' ,
230+ ];
231+
232+ $ token = $ this ->getAccessToken ($ options );
233+
234+ $ this ->assertSame ($ token ->getTimeNow (), $ token ->getExpires ());
235+ }
236+
237+ public function testInvalidExpiresWhenExpiresCastsToInteger ()
238+ {
239+ $ options = [
240+ 'access_token ' => 'access_token ' ,
241+ 'expires ' => '3TEXT ' ,
242+ ];
243+
244+ $ token = $ this ->getAccessToken ($ options );
245+
246+ $ this ->assertSame ($ token ->getTimeNow () + 3 , $ token ->getExpires ());
247+ $ this ->assertFalse ($ token ->hasExpired ());
248+
249+ self ::tearDownForBackwardsCompatibility ();
250+ }
225251
226252 public function testJsonSerializable ()
227253 {
You can’t perform that action at this time.
0 commit comments