Skip to content

Commit

Permalink
add sub to resource owner toArray() (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradtke committed Oct 1, 2022
1 parent 16c3708 commit cb1bf60
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Provider/Apple.php
Expand Up @@ -218,6 +218,7 @@ protected function createResourceOwner(array $response, AccessToken $token)
{
return new AppleResourceOwner(
array_merge(
['sub' => $token->getResourceOwnerId()],
$response,
[
'email' => isset($token->getValues()['email'])
Expand Down
34 changes: 34 additions & 0 deletions test/src/Provider/AppleTest.php
Expand Up @@ -296,6 +296,40 @@ public function testCheckResponse()
]]);
}

public function testResourceToArrayHasAttributes()
{
$provider = $this->getProvider();
$class = new \ReflectionClass($provider);
$method = $class->getMethod('createResourceOwner');
$method->setAccessible(true);

/** @var AppleResourceOwner $data */
$data = $method->invokeArgs($provider, [
[
'email' => 'john@doe.com',// <- Fake E-Mail from user input
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
]
],
new AccessToken([
'access_token' => 'hello',
'email' => 'john@doe.de',
'resource_owner_id' => '123.4.567'
])
]);
$expectedArray = [
'email' => 'john@doe.de',
'sub' => '123.4.567',
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
],
'isPrivateEmail' => null
];
$this->assertEquals($expectedArray, $data->toArray());
}

public function testCreationOfResourceOwnerWithName()
{
$provider = $this->getProvider();
Expand Down

0 comments on commit cb1bf60

Please sign in to comment.