From a9ff2bfcdf9ebc9c61ceb93d4b2eb1e6cac2fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= <1005065+DeepDiver1975@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:57:43 +0200 Subject: [PATCH] fix: method signatures after 1.0 release --- src/OpenIDConnectClient.php | 10 ++++++---- tests/OpenIDConnectClientTest.php | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/OpenIDConnectClient.php b/src/OpenIDConnectClient.php index adabf80c..ee3c971d 100644 --- a/src/OpenIDConnectClient.php +++ b/src/OpenIDConnectClient.php @@ -1221,10 +1221,9 @@ protected function urlEncode(string $str): string /** * @param string $jwt encoded JWT * @param int $section the section we would like to decode - * @return object + * @return object|null */ - protected function decodeJWT(string $jwt, int $section = 0): stdClass { - + protected function decodeJWT(string $jwt, int $section = 0) { $parts = explode('.', $jwt); return json_decode(base64url_decode($parts[$section]), false); } @@ -1725,7 +1724,10 @@ public function getAccessToken(): string return $this->accessToken; } - public function getRefreshToken(): string + /** + * @return string|null + */ + public function getRefreshToken() { return $this->refreshToken; } diff --git a/tests/OpenIDConnectClientTest.php b/tests/OpenIDConnectClientTest.php index f895879c..793c320f 100644 --- a/tests/OpenIDConnectClientTest.php +++ b/tests/OpenIDConnectClientTest.php @@ -7,9 +7,22 @@ class OpenIDConnectClientTest extends TestCase { - /** - * @return void - */ + public function testJWTDecode() + { + $client = new OpenIDConnectClient(); + $client->setAccessToken(''); + $header = $client->getAccessTokenHeader(); + self::assertEquals('', $header); + } + + public function testGetNullRefreshToken() + { + $client = new OpenIDConnectClient(); + $client->setAccessToken(''); + $token = $client->getRefreshToken(); + self::assertEquals('', $token); + } + public function testGetRedirectURL() { $client = new OpenIDConnectClient();