Removed private property reader hack

This commit is contained in:
Alex Bilbie 2014-01-16 17:27:05 +00:00
parent a5b4198cb7
commit 40ea409aed
2 changed files with 14 additions and 19 deletions

View File

@ -13,19 +13,15 @@ class RefreshTokenTests extends \PHPUnit_Framework_TestCase
{ {
function testSetAccessToken() function testSetAccessToken()
{ {
$reader = function & ($object, $property) {
$value = & \Closure::bind(function & () use ($property) {
return $this->$property;
}, $object, $object)->__invoke();
return $value;
};
$server = M::mock('League\OAuth2\Server\AbstractServer'); $server = M::mock('League\OAuth2\Server\AbstractServer');
$entity = new RefreshToken($server); $entity = new RefreshToken($server);
$entity->setAccessToken((new AccessToken($server))); $entity->setAccessToken((new AccessToken($server)));
$this->assertTrue($reader($entity, 'accessToken') instanceof AccessToken); $reflector = new \ReflectionClass($entity);
$accessTokenProperty = $reflector->getProperty('accessToken');
$accessTokenProperty->setAccessible(true);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessToken);
} }
function testSave() function testSave()

View File

@ -25,21 +25,20 @@ class SessionTests extends \PHPUnit_Framework_TestCase
$entity->associateScope((new Scope($server))->setId('foo')); $entity->associateScope((new Scope($server))->setId('foo'));
// $entity->associateAuthCode((new AuthCode($server))); // $entity->associateAuthCode((new AuthCode($server)));
$reader = function & ($object, $property) {
$value = & \Closure::bind(function & () use ($property) {
return $this->$property;
}, $object, $object)->__invoke();
return $value;
};
$this->assertEquals('foobar', $entity->getId()); $this->assertEquals('foobar', $entity->getId());
$this->assertEquals('user', $entity->getOwnerType()); $this->assertEquals('user', $entity->getOwnerType());
$this->assertEquals(123, $entity->getOwnerId()); $this->assertEquals(123, $entity->getOwnerId());
$this->assertTrue($reader($entity, 'accessToken') instanceof AccessToken);
$this->assertTrue($reader($entity, 'refreshToken') instanceof RefreshToken);
$this->assertTrue($entity->getClient() instanceof Client); $this->assertTrue($entity->getClient() instanceof Client);
$this->assertTrue($entity->hasScope('foo')); $this->assertTrue($entity->hasScope('foo'));
$reflector = new \ReflectionClass($entity);
$accessTokenProperty = $reflector->getProperty('accessToken');
$accessTokenProperty->setAccessible(true);
$refreshTokenProperty = $reflector->getProperty('refreshToken');
$refreshTokenProperty->setAccessible(true);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessToken);
$this->assertTrue($refreshTokenProperty->getValue($entity) instanceof RefreshToken);
// $this->assertTrue($reader($entity, 'authCode') instanceof AuthCode); // $this->assertTrue($reader($entity, 'authCode') instanceof AuthCode);
} }