mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Removed private property reader hack
This commit is contained in:
parent
a5b4198cb7
commit
40ea409aed
@ -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()
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user