Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Dec 28, 2017
1 parent 5e4bb86 commit bbc890f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ public function getOriginal()
*/
public function jsonSerialize()
{
return array_merge($this->attributes, ['token' => $this->token->getAttributes()]);
return array_merge($this->attributes, ['token' => $this->token ? $this->token->getAttributes() : null]);
}
}
15 changes: 15 additions & 0 deletions tests/UserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php


use Overtrue\Socialite\AccessToken;
use Overtrue\Socialite\User;

class UserTest extends \PHPUnit_Framework_TestCase
{
public function testJsonserialize()
{
$this->assertSame('{"token":null}', json_encode(new User([])));

$this->assertSame('{"token":{"access_token":"mock-token"}}', json_encode(new User(['token' => new AccessToken(['access_token' => 'mock-token'])])));
}
}

0 comments on commit bbc890f

Please sign in to comment.