Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sub to resource owner toArray() #38

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Provider/Apple.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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' => '[email protected]',// <- Fake E-Mail from user input
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
]
],
new AccessToken([
'access_token' => 'hello',
'email' => '[email protected]',
'resource_owner_id' => '123.4.567'
])
]);
$expectedArray = [
'email' => '[email protected]',
'sub' => '123.4.567',
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
],
'isPrivateEmail' => null
];
$this->assertEquals($expectedArray, $data->toArray());
}

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