diff --git a/tests/Entities/RefreshTokenTest.php b/tests/Entities/RefreshTokenTest.php index e762326c..067e976c 100644 --- a/tests/Entities/RefreshTokenTest.php +++ b/tests/Entities/RefreshTokenTest.php @@ -13,19 +13,15 @@ class RefreshTokenTests extends \PHPUnit_Framework_TestCase { 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'); $entity = new RefreshToken($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() diff --git a/tests/Entities/SessionTest.php b/tests/Entities/SessionTest.php index 100001dd..b9a97490 100644 --- a/tests/Entities/SessionTest.php +++ b/tests/Entities/SessionTest.php @@ -25,21 +25,20 @@ class SessionTests extends \PHPUnit_Framework_TestCase $entity->associateScope((new Scope($server))->setId('foo')); // $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('user', $entity->getOwnerType()); $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->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); }