diff --git a/src/AuthenticationService.php b/src/AuthenticationService.php index 44dd6bf8..b25c126f 100644 --- a/src/AuthenticationService.php +++ b/src/AuthenticationService.php @@ -247,9 +247,7 @@ public function persistIdentity(ServerRequestInterface $request, ResponseInterfa } } - if (!($identity instanceof IdentityInterface)) { - $identity = $this->buildIdentity($identity); - } + $identity = $this->buildIdentity($identity); return [ 'request' => $request->withAttribute($this->getConfig('identityAttribute'), $identity), diff --git a/tests/TestCase/AuthenticationServiceTest.php b/tests/TestCase/AuthenticationServiceTest.php index 8f1a21d3..15379e24 100644 --- a/tests/TestCase/AuthenticationServiceTest.php +++ b/tests/TestCase/AuthenticationServiceTest.php @@ -396,13 +396,13 @@ public function testPersistIdentityInterface() { $request = new ServerRequest(); $response = new Response(); - $identity = $this->createMock(IdentityInterface::class); + $identity = new ArrayObject(); $service = new AuthenticationService(); $result = $service->persistIdentity($request, $response, $identity); - $this->assertSame($identity, $result['request']->getAttribute('identity')); + $this->assertInstanceOf(IdentityInterface::class, $result['request']->getAttribute('identity')); } /**