Permalink
Browse files

Add access_token and resourceOwnerName to serialization of OAuthToken…

…. Closes #9
  • Loading branch information...
1 parent f27b2ed commit 086026c46100f8f2ecc859d7b6d5950e6cb86ab3 @asm89 asm89 committed May 25, 2012
@@ -77,4 +77,30 @@ public function setResourceOwnerName($resourceOwnerName)
{
$this->resourceOwnerName = $resourceOwnerName;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public function serialize()
+ {
+ return serialize(array(
+ $this->accessToken,
+ $this->resourceOwnerName,
+ parent::serialize()
+ ));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function unserialize($serialized)
+ {
+ list(
+ $this->accessToken,
+ $this->resourceOwnerName,
+ $parent,
+ ) = unserialize($serialized);
+
+ parent::unserialize($parent);
+ }
}
@@ -19,6 +19,7 @@ class OAuthTokenTest extends \PHPUnit_Framework_Testcase
public function setup()
{
$this->token = new OAuthToken('access_token', array('ROLE_TEST'));
+ $this->token->setResourceOwnerName('github');
}
public function testGetCredentials()
@@ -36,4 +37,12 @@ public function testGetSetResourceOwnerName()
$this->token->setResourceOwnerName('github');
$this->assertEquals('github', $this->token->getResourceOwnerName());
}
+
+ public function testSerialization()
+ {
+ $token = unserialize(serialize($this->token));
+
+ $this->assertEquals('access_token', $token->getCredentials());
+ $this->assertEquals('github', $token->getResourceOwnerName());
+ }
}

0 comments on commit 086026c

Please sign in to comment.