Skip to content

Commit

Permalink
test coverage report generation and refactoring userDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Maguire committed Apr 14, 2015
1 parent 5ed7d04 commit fd23f0d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,28 @@
stopOnFailure="false"
syntaxCheck="false"
>
<logging>
<log type="coverage-html"
target="./build/coverage/html"
charset="UTF-8"
highlight="false"
lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-clover"
target="./build/coverage/log/coverage.xml"/>
</logging>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./test</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
31 changes: 19 additions & 12 deletions src/Provider/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ public function userDetails($response, AccessToken $token)
{
$user = new User();

$email = (isset($response->emailAddress)) ? $response->emailAddress : null;
$location = (isset($response->location->name)) ? $response->location->name : null;
$description = (isset($response->headline)) ? $response->headline : null;
$pictureUrl = (isset($response->pictureUrl)) ? $response->pictureUrl : null;
$id = $this->issetAndGetValue($response->id);
$firstName = $this->issetAndGetValue($response->firstName);
$lastName = $this->issetAndGetValue($response->lastName);
$email = $this->issetAndGetValue($response->emailAddress);
$location = $this->issetAndGetValue($response->location->name);
$description = $this->issetAndGetValue($response->headline);
$pictureUrl = $this->issetAndGetValue($response->pictureUrl);
$publicProfileUrl = $this->issetAndGetValue($response->publicProfileUrl);

$user->exchangeArray([
'uid' => $response->id,
'name' => $response->firstName.' '.$response->lastName,
'firstname' => $response->firstName,
'lastname' => $response->lastName,
'uid' => $id,
'name' => $firstName.' '.$lastName,
'firstname' => $firstName,
'lastname' => $lastName,
'email' => $email,
'location' => $location,
'description' => $description,
'imageurl' => $pictureUrl,
'urls' => $response->publicProfileUrl,
'urls' => $publicProfileUrl,
]);

return $user;
Expand All @@ -62,13 +66,16 @@ public function userUid($response, AccessToken $token)

public function userEmail($response, AccessToken $token)
{
return isset($response->emailAddress) && $response->emailAddress
? $response->emailAddress
: null;
return $this->issetAndGetValue($response->emailAddress);
}

public function userScreenName($response, AccessToken $token)
{
return [$response->firstName, $response->lastName];
}

private function issetAndGetValue($item)
{
return isset($item) ? $item : null;
}
}

0 comments on commit fd23f0d

Please sign in to comment.