Updated tests

This commit is contained in:
Alex Bilbie 2014-07-11 18:19:10 +01:00
parent 48dea185d8
commit c6bc1b0cfc
13 changed files with 115 additions and 101 deletions

View File

@ -16,12 +16,12 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$time = time();
$entity = new StubAbstractTokenEntity($server);
$entity->setToken('foobar');
$entity->setId('foobar');
$entity->setExpireTime($time);
$entity->setSession((new SessionEntity($server)));
$entity->associateScope((new ScopeEntity($server))->setId('foo'));
$entity->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
$this->assertEquals('foobar', $entity->getToken());
$this->assertEquals('foobar', $entity->getId());
$this->assertEquals($time, $entity->getExpireTime());
// $this->assertTrue($entity->getSession() instanceof SessionEntity);
// $this->assertTrue($entity->hasScope('foo'));
@ -92,8 +92,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$method->setAccessible(true);
$scopes = [
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
(new ScopeEntity($server))->hydrate(['id' => 'scope1', 'description' => 'foo']),
(new ScopeEntity($server))->hydrate(['id' => 'scope2', 'description' => 'bar'])
];
$result = $method->invokeArgs($entity, [$scopes]);
@ -110,7 +110,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$entity = new StubAbstractTokenEntity($server);
$this->assertEquals('', (string) $entity);
$entity->setToken('foobar');
$entity->setId('foobar');
$this->assertEquals('foobar', (string) $entity);
}
}

View File

@ -20,7 +20,7 @@ class AccessTokenTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('associateScope');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');

View File

@ -18,7 +18,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$code = new AuthCodeEntity($server);
$code->setRedirectUri('http://foo/bar');
$code->setToken('foobar');
$code->setId('foobar');
$code->setSession($session);
$this->assertEquals('http://foo/bar', $code->getRedirectUri());
@ -37,7 +37,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$authCodeStorage->shouldReceive('associateScope');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$server->shouldReceive('getStorage')->with('auth_code')->andReturn($authCodeStorage);

View File

@ -10,11 +10,12 @@ class ClientTest extends \PHPUnit_Framework_TestCase
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$client = new ClientEntity($server);
$client->setId('foobar');
$client->setSecret('barfoo');
$client->setName('Test Client');
$client->setRedirectUri('http://foo/bar');
$client = (new ClientEntity($server))->hydrate([
'id' => 'foobar',
'secret' => 'barfoo',
'name' => 'Test Client',
'redirectUri' => 'http://foo/bar'
]);
$this->assertEquals('foobar', $client->getId());
$this->assertEquals('barfoo', $client->getSecret());

View File

@ -39,10 +39,10 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
(new AccessTokenEntity($server))->setToken('foobar')
(new AccessTokenEntity($server))->setId('foobar')
);
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);

View File

@ -10,9 +10,10 @@ class ScopeTest extends \PHPUnit_Framework_TestCase
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$scope = new ScopeEntity($server);
$scope->setId('foobar');
$scope->setDescription('barfoo');
$scope = (new ScopeEntity($server))->hydrate([
'id' => 'foobar',
'description' => 'barfoo'
]);
$this->assertEquals('foobar', $scope->getId());
$this->assertEquals('barfoo', $scope->getDescription());

View File

@ -14,14 +14,22 @@ class SessionTest extends \PHPUnit_Framework_TestCase
{
public function testSetGet()
{
$emitter = M::mock('League\Event\Emitter');
$emitter->shouldReceive('emit');
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setEventEmitter');
$server->shouldReceive('getEventEmitter')->andReturn($emitter);
$server->setEventEmitter($emitter);
$entity = new SessionEntity($server);
$entity->setId('foobar');
$entity->setOwner('user', 123);
$entity->associateAccessToken((new AccessTokenEntity($server)));
$entity->associateRefreshToken((new RefreshTokenEntity($server)));
$entity->associateClient((new ClientEntity($server)));
$entity->associateScope((new ScopeEntity($server))->setId('foo'));
$entity->associateScope(
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
// $entity->associateAuthCode((new AuthCode($server)));
$this->assertEquals('foobar', $entity->getId());
@ -51,8 +59,8 @@ class SessionTest extends \PHPUnit_Framework_TestCase
$method->setAccessible(true);
$scopes = [
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
(new ScopeEntity($server))->hydrate(['id' => 'scope1']),
(new ScopeEntity($server))->hydrate(['id' => 'scope2'])
];
$result = $method->invokeArgs($entity, [$scopes]);
@ -124,14 +132,14 @@ class SessionTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('associateScope');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new ClientEntity($server))->setId('foo')
(new ClientEntity($server))->hydrate(['id' => 'foo'])
);
$clientStorage->shouldReceive('setServer');

View File

@ -36,8 +36,8 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$method->setAccessible(true);
$scopes = [
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
(new ScopeEntity($server))->hydrate(['id' => 'scope1', 'description' => 'foo']),
(new ScopeEntity($server))->hydrate(['id' => 'scope2', 'description' => 'bar'])
];
$result = $method->invokeArgs($grant, [$scopes]);
@ -55,7 +55,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setScopeStorage($scopeStorage);
@ -65,9 +65,8 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
[
'foo' => (new ScopeEntity($server))->setId('foo')
'foo' => (new ScopeEntity($server))->hydrate(['id' => 'foo'])
],
$grant->validateScopes('foo')
);
}
@ -113,7 +112,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setScopeStorage($scopeStorage);
@ -134,7 +133,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setScopeStorage($scopeStorage);

View File

@ -144,7 +144,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -185,14 +185,14 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage->shouldReceive('associateScope');
@ -200,14 +200,14 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -229,9 +229,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
public function testNewAuthoriseRequest()
{
$server = new AuthorizationServer;
$client = (new ClientEntity($server))->setId('testapp');
$scope = (new ScopeEntity($server))->setId('foo');
$client = (new ClientEntity($server))->hydrate(['id' => 'testapp']);
$scope = (new ScopeEntity($server))->hydrate(['id' => 'foo']);
$grant = new AuthCodeGrant;
$server->addGrantType($grant);
@ -346,7 +345,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -395,7 +394,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -444,7 +443,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -464,7 +463,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://fail/face')
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://fail/face')
);
$server->setClientStorage($clientStorage);
@ -493,10 +492,10 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -506,29 +505,32 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
(new SessionEntity($server))->setId('foobar')
);
$sessionStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('associateScope');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('delete');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://foo/bar')
);
$authCodeStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$server->setClientStorage($clientStorage);
@ -558,10 +560,10 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -571,29 +573,32 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
(new SessionEntity($server))->setId('foobar')
);
$sessionStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('associateScope');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('delete');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
(new AuthCodeEntity($server))->setId('foobar')->setRedirectUri('http://foo/bar')
);
$authCodeStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');

View File

@ -80,7 +80,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -120,7 +120,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -138,7 +138,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
// $scopeStorage->shouldReceive('get')->andReturn(
// // (new ScopeEntity($server))->setId('foo')
// // (new ScopeEntity($server))->hydrate(['id' => 'foo'])
// );
$server->setClientStorage($clientStorage);
@ -165,14 +165,14 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage->shouldReceive('associateScope');
@ -180,14 +180,14 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -228,7 +228,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);

View File

@ -80,7 +80,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -123,7 +123,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -167,7 +167,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -212,7 +212,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -259,7 +259,7 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -309,14 +309,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage->shouldReceive('associateScope');
@ -324,14 +324,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -363,14 +363,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage->shouldReceive('associateScope');
@ -378,14 +378,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -422,14 +422,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$sessionStorage->shouldReceive('associateScope');
@ -437,14 +437,14 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');

View File

@ -92,7 +92,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -127,7 +127,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
@ -161,7 +161,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -180,7 +180,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
@ -196,7 +196,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -228,12 +228,12 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$server = new AuthorizationServer;
$grant = new RefreshTokenGrant;
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -252,7 +252,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
@ -268,7 +268,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
);
$server->setClientStorage($clientStorage);
@ -300,12 +300,12 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$server = new AuthorizationServer;
$grant = new RefreshTokenGrant;
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->hydrate(['id' => 'foo']));
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@ -324,7 +324,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo')
(new ScopeEntity($server))->hydrate(['id' => 'foo'])
]);
$accessTokenStorage->shouldReceive('associateScope');
@ -340,7 +340,7 @@ class RefreshTokenGreantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new ScopeEntity($server))->setId('blah')
(new ScopeEntity($server))->hydrate(['id' => 'blah'])
);
$server->setClientStorage($clientStorage);

View File

@ -135,23 +135,23 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
$scopeStorage
);
$server->setTokenKey('at');
$server->setIdKey('at');
$accessTokenStorage->shouldReceive('get')->andReturn(
(new AccessTokenEntity($server))->setToken('abcdef')
(new AccessTokenEntity($server))->setId('abcdef')
);
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new ScopeEntity($server))->setId('foo'),
(new ScopeEntity($server))->setId('bar')
]);
// $accessTokenStorage->shouldReceive('getScopes')->andReturn([
// (new ScopeEntity($server))->hydrate(['id' => 'foo']),
// (new ScopeEntity($server))->hydrate(['id' => 'bar'])
// ]);
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
(new SessionEntity($server))->setId('foobar')->setOwner('user', 123)
);
$clientStorage->shouldReceive('getBySession')->andReturn(
(new ClientEntity($server))->setId('testapp')
(new ClientEntity($server))->hydrate(['id' => 'testapp'])
);
$request = new \Symfony\Component\HttpFoundation\Request();
@ -161,7 +161,7 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
$server->setRequest($request);
$this->assertTrue($server->isValidRequest());
$this->assertEquals('at', $server->getTokenKey());
$this->assertEquals('at', $server->getIdKey());
$this->assertEquals(123, $server->getOwnerId());
$this->assertEquals('user', $server->getOwnerType());
$this->assertEquals('abcdef', $server->getAccessToken());