Skip to content

Commit

Permalink
Add test for userFields option
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowhand committed Aug 13, 2015
1 parent a124553 commit 3d33dc4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/src/Provider/GoogleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,45 @@ public function testResourceOwnerDetailsUrl()

$this->assertEquals('/plus/v1/people/me', $uri['path']);
$this->assertNotContains('mock_access_token', $url);

}

public function testResourceOwnerDetailsUrlCustomFields()
{
$provider = new GoogleProvider([
'clientId' => 'mock_client_id',
'clientSecret' => 'mock_secret',
'redirectUri' => 'none',
'userFields' => [
'domain',
'gender',
'verified',
],
]);

$token = m::mock('League\OAuth2\Client\Token\AccessToken', [['access_token' => 'mock_access_token']]);

$url = $provider->getResourceOwnerDetailsUrl($token);
$uri = parse_url($url);
parse_str($uri['query'], $query);

$this->assertArrayHasKey('fields', $query);
$this->assertArrayHasKey('alt', $query);

// Always JSON for consistency
$this->assertEquals('json', $query['alt']);

$fields = explode(',', $query['fields']);

// Default values
$this->assertContains('displayName', $fields);
$this->assertContains('emails/value', $fields);
$this->assertContains('image/url', $fields);

// Configured values
$this->assertContains('domain', $fields);
$this->assertContains('gender', $fields);
$this->assertContains('verified', $fields);
}

public function testUserData()
Expand Down

0 comments on commit 3d33dc4

Please sign in to comment.