diff --git a/src/Esia/OpenId.php b/src/Esia/OpenId.php index 8524d9e..cee752b 100755 --- a/src/Esia/OpenId.php +++ b/src/Esia/OpenId.php @@ -87,10 +87,10 @@ public function getConfig(): Config * @return string|false * @throws SignFailException */ - public function buildUrl() + public function buildUrl(string $state = null) { $timestamp = $this->getTimeStamp(); - $state = $this->buildState(); + $state = $state ?? $this->buildState(); $message = $this->config->getScopeString() . $timestamp . $this->config->getClientId() diff --git a/tests/unit/OpenIdTest.php b/tests/unit/OpenIdTest.php index 9b0e399..1133a98 100644 --- a/tests/unit/OpenIdTest.php +++ b/tests/unit/OpenIdTest.php @@ -156,6 +156,13 @@ public function testGetDocInfo(): void self::assertSame([['phone' => '555 555 555'], ['email' => 'test@gmail.com']], $info); } + public function testBuildUrl(): void + { + $state = '47e1f1e9-8b56-4666-ac02-d1408408e5f2'; + $url = $this->openId->buildUrl($state); + self::assertStringContainsString($state, $url); + } + /** * @throws InvalidConfigurationException */