Updated with new entity names

This commit is contained in:
Alex Bilbie
2014-05-02 17:21:53 +01:00
parent 8fbbc7bd07
commit 97fd115530
18 changed files with 244 additions and 218 deletions

View File

@@ -10,7 +10,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$client = new Client($server);
$client = new ClientEntity($server);
$client->setId('foobar');
$client->setSecret('barfoo');
$client->setName('Test Client');

View File

@@ -14,58 +14,69 @@ class RefreshTokenTests extends \PHPUnit_Framework_TestCase
function testSetAccessToken()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$entity = new RefreshToken($server);
$entity->setAccessToken((new AccessToken($server)));
$entity = new RefreshTokenEntity($server);
$entity->setAccessToken((new AccessTokenEntity($server)));
$reflector = new \ReflectionClass($entity);
$accessTokenProperty = $reflector->getProperty('accessToken');
$accessTokenProperty->setAccessible(true);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessToken);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessTokenEntity);
}
function testSave()
{
$server = new Authorization();
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setAccessTokenStorage');
$server->shouldReceive('setRefreshTokenStorage');
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
$refreshTokenStorage->shouldReceive('create');
$refreshTokenStorage->shouldReceive('setServer');
$refreshTokenStorage->shouldReceive('associateScope');
$server->shouldReceive('getStorage')->with('refresh_token')->andReturn($refreshTokenStorage);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
(new AccessToken($server))->setToken('foobar')
(new AccessTokenEntity($server))->setToken('foobar')
);
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
(new Session($server))
(new SessionEntity($server))
);
$sessionStorage->shouldReceive('setServer');
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
$server->setAccessTokenStorage($accessTokenStorage);
$server->setRefreshTokenStorage($refreshTokenStorage);
$entity = new RefreshToken($server);
$entity = new RefreshTokenEntity($server);
$this->assertSame(null, $entity->save());
}
function testExpire()
{
$server = new Authorization();
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setRefreshTokenStorage');
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
$refreshTokenStorage->shouldReceive('delete');
$refreshTokenStorage->shouldReceive('setServer');
$server->shouldReceive('getStorage')->with('refresh_token')->andReturn($refreshTokenStorage);
$server->setRefreshTokenStorage($refreshTokenStorage);
$entity = new RefreshToken($server);
$entity = new RefreshTokenEntity($server);
$this->assertSame($entity->expire(), null);
}
}

View File

@@ -10,7 +10,7 @@ class ScopeTests extends \PHPUnit_Framework_TestCase
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$scope = new Scope($server);
$scope = new ScopeEntity($server);
$scope->setId('foobar');
$scope->setDescription('barfoo');

View File

@@ -8,7 +8,7 @@ use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\AuthorizationServer as Authorization;
use League\OAuth2\Server\AuthorizationServer;
use \Mockery as M;
class SessionTests extends \PHPUnit_Framework_TestCase
@@ -16,19 +16,19 @@ class SessionTests extends \PHPUnit_Framework_TestCase
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$entity = new Session($server);
$entity = new SessionEntity($server);
$entity->setId('foobar');
$entity->setOwner('user', 123);
$entity->associateAccessToken((new AccessToken($server)));
$entity->associateRefreshToken((new RefreshToken($server)));
$entity->associateClient((new Client($server)));
$entity->associateScope((new Scope($server))->setId('foo'));
$entity->associateAccessToken((new AccessTokenEntity($server)));
$entity->associateRefreshToken((new RefreshTokenEntity($server)));
$entity->associateClient((new ClientEntity($server)));
$entity->associateScope((new ScopeEntity($server))->setId('foo'));
// $entity->associateAuthCode((new AuthCode($server)));
$this->assertEquals('foobar', $entity->getId());
$this->assertEquals('user', $entity->getOwnerType());
$this->assertEquals(123, $entity->getOwnerId());
$this->assertTrue($entity->getClient() instanceof Client);
$this->assertTrue($entity->getClient() instanceof ClientEntity);
$this->assertTrue($entity->hasScope('foo'));
$reflector = new \ReflectionClass($entity);
@@ -37,8 +37,8 @@ class SessionTests extends \PHPUnit_Framework_TestCase
$refreshTokenProperty = $reflector->getProperty('refreshToken');
$refreshTokenProperty->setAccessible(true);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessToken);
$this->assertTrue($refreshTokenProperty->getValue($entity) instanceof RefreshToken);
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessTokenEntity);
$this->assertTrue($refreshTokenProperty->getValue($entity) instanceof RefreshTokenEntity);
// $this->assertTrue($reader($entity, 'authCode') instanceof AuthCode);
}
@@ -46,32 +46,36 @@ class SessionTests extends \PHPUnit_Framework_TestCase
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$entity = new Session($server);
$reflectedEntity = new \ReflectionClass('League\OAuth2\Server\Entity\Session');
$entity = new SessionEntity($server);
$reflectedEntity = new \ReflectionClass('League\OAuth2\Server\Entity\SessionEntity');
$method = $reflectedEntity->getMethod('formatScopes');
$method->setAccessible(true);
$scopes = [
(new Scope($server))->setId('scope1')->setDescription('foo'),
(new Scope($server))->setId('scope2')->setDescription('bar')
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
];
$result = $method->invokeArgs($entity, [$scopes]);
$this->assertTrue(isset($result['scope1']));
$this->assertTrue(isset($result['scope2']));
$this->assertTrue($result['scope1'] instanceof Scope);
$this->assertTrue($result['scope2'] instanceof Scope);
$this->assertTrue($result['scope1'] instanceof ScopeEntity);
$this->assertTrue($result['scope2'] instanceof ScopeEntity);
}
public function testGetScopes()
{
$server = new Authorization();
$server = M::mock('League\OAuth2\Server\AuthorizationServer');
$server->shouldReceive('setAccessTokenStorage');
$server->shouldReceive('setSessionStorage');
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$server->setAccessTokenStorage($accessTokenStorage);
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('getScopes')->andReturn(
[]
@@ -79,18 +83,24 @@ class SessionTests extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('setServer');
$server->setSessionStorage($sessionStorage);
$entity = new Session($server);
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
$entity = new SessionEntity($server);
$this->assertEquals($entity->getScopes(), []);
}
public function testHasScopes()
{
$server = new Authorization();
$server = M::mock('League\OAuth2\Server\AuthorizationServer');
$server->shouldReceive('setAccessTokenStorage');
$server->shouldReceive('setSessionStorage');
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$server->setAccessTokenStorage($accessTokenStorage);
$server->shouldReceive('getStorage')->with('access_token')->andReturn($accessTokenStorage);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('getScopes')->andReturn(
[]
@@ -98,32 +108,40 @@ class SessionTests extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('setServer');
$server->setSessionStorage($sessionStorage);
$entity = new Session($server);
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
$entity = new SessionEntity($server);
$this->assertFalse($entity->hasScope('foo'));
}
function testSave()
{
$server = new Authorization();
$server = M::mock('League\OAuth2\Server\AuthorizationServer');
$server->shouldReceive('setSessionStorage');
$server->shouldReceive('setClientStorage');
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('create');
$sessionStorage->shouldReceive('associateScope');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$server->shouldReceive('getStorage')->with('session')->andReturn($sessionStorage);
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new Client($server))->setId('foo')
(new ClientEntity($server))->setId('foo')
);
$clientStorage->shouldReceive('setServer');
$server->shouldReceive('getStorage')->with('client')->andReturn($clientStorage);
$server->setSessionStorage($sessionStorage);
$server->setClientStorage($clientStorage);
$entity = new Session($server);
$entity = new SessionEntity($server);
$this->assertEquals(null, $entity->save());
}
}

View File

@@ -36,16 +36,16 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$method->setAccessible(true);
$scopes = [
(new Scope($server))->setId('scope1')->setDescription('foo'),
(new Scope($server))->setId('scope2')->setDescription('bar')
(new ScopeEntity($server))->setId('scope1')->setDescription('foo'),
(new ScopeEntity($server))->setId('scope2')->setDescription('bar')
];
$result = $method->invokeArgs($grant, [$scopes]);
$this->assertTrue(isset($result['scope1']));
$this->assertTrue(isset($result['scope2']));
$this->assertTrue($result['scope1'] instanceof Scope);
$this->assertTrue($result['scope2'] instanceof Scope);
$this->assertTrue($result['scope1'] instanceof ScopeEntity);
$this->assertTrue($result['scope2'] instanceof ScopeEntity);
}
public function testValidateScopes()
@@ -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 Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setScopeStorage($scopeStorage);
@@ -65,7 +65,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(
[
'foo' => (new Scope($server))->setId('foo')
'foo' => (new ScopeEntity($server))->setId('foo')
],
$grant->validateScopes('foo')
@@ -113,7 +113,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setScopeStorage($scopeStorage);
@@ -134,7 +134,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setScopeStorage($scopeStorage);

View File

@@ -7,8 +7,8 @@ use League\OAuth2\Server\Grant\RefreshToken;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\AuthCode as AC;
use League\OAuth2\Server\AuthorizationServer as Authorization;
use League\OAuth2\Server\Entity\AuthCodeEntity;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\InvalidRequestException;
use Mockery as M;
@@ -30,8 +30,8 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
$_POST = [];
$server = new AuthorizationServer;
$server = new Authorization;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -43,11 +43,11 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
$server = new AuthorizationServer;
$_POST = [
'client_id' => 'testapp'
];
$server = new Authorization;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -62,10 +62,10 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'client_id' => 'testapp',
'redirect_uri' => 'http://foo/bar'
];
$server = new AuthorizationServer;
$server = new Authorization;
$server->requireStateParam(true);
$grant = new AuthCode;
$server->requireStateParam(true);
$server->addGrantType($grant);
$grant->checkAuthoriseParams();
@@ -79,8 +79,8 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'client_id' => 'testapp',
'redirect_uri' => 'http://foo/bar'
];
$server = new AuthorizationServer;
$server = new Authorization;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -96,8 +96,8 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'redirect_uri' => 'http://foo/bar',
'response_type' => 'foobar'
];
$server = new AuthorizationServer;
$server = new Authorization;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -113,14 +113,15 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'redirect_uri' => 'http://foo/bar',
'response_type' => 'code'
];
$server = new AuthorizationServer;
$server = new Authorization;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(null);
$server->setClientStorage($clientStorage);
$server->addGrantType($grant);
@@ -138,13 +139,13 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'scope' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -179,20 +180,20 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'scope' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$sessionStorage->shouldReceive('associateScope');
@@ -200,14 +201,14 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);
@@ -219,19 +220,19 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$result = $grant->checkAuthoriseParams();
$this->assertTrue($result['client'] instanceof Client);
$this->assertTrue($result['client'] instanceof ClientEntity);
$this->assertTrue($result['redirect_uri'] === $_POST['redirect_uri']);
$this->assertTrue($result['state'] === null);
$this->assertTrue($result['response_type'] === 'code');
$this->assertTrue($result['scopes']['foo'] instanceof Scope);
$this->assertTrue($result['scopes']['foo'] instanceof ScopeEntity);
}
public function testNewAuthoriseRequest()
{
$server = new Authorization;
$server = new AuthorizationServer;
$client = (new Client($server))->setId('testapp');
$scope = (new Scope($server))->setId('foo');
$client = (new ClientEntity($server))->setId('testapp');
$scope = (new ScopeEntity($server))->setId('foo');
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -264,7 +265,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'authorization_code';
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -281,7 +282,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'client_id' => 'testapp'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -298,7 +299,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'client_secret' => 'foobar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$server->addGrantType($grant);
@@ -316,7 +317,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'redirect_uri' => 'http://foo/bar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
@@ -340,13 +341,13 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'redirect_uri' => 'http://foo/bar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -389,13 +390,13 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'code' => 'foobar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -438,13 +439,13 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'code' => 'foobar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -464,7 +465,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AC($server))->setToken('foobar')->setRedirectUri('http://fail/face')
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://fail/face')
);
$server->setClientStorage($clientStorage);
@@ -487,16 +488,16 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'code' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -504,7 +505,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('associateScope');
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
(new Session($server))->setId('foobar')
(new SessionEntity($server))->setId('foobar')
);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
@@ -512,23 +513,23 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('associateScope');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('delete');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AC($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
);
$authCodeStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$server->setClientStorage($clientStorage);
@@ -551,17 +552,17 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
'code' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new AuthCode;
$rtgrant = new RefreshToken;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('getBySession')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -569,7 +570,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('associateScope');
$sessionStorage->shouldReceive('getByAuthCode')->andReturn(
(new Session($server))->setId('foobar')
(new SessionEntity($server))->setId('foobar')
);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
@@ -577,23 +578,23 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('associateScope');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$authCodeStorage = M::mock('League\OAuth2\Server\Storage\AuthCodeInterface');
$authCodeStorage->shouldReceive('setServer');
$authCodeStorage->shouldReceive('delete');
$authCodeStorage->shouldReceive('get')->andReturn(
(new AC($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
(new AuthCodeEntity($server))->setToken('foobar')->setRedirectUri('http://foo/bar')
);
$authCodeStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');

View File

@@ -5,7 +5,7 @@ namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\ClientCredentials;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\AuthorizationServer as Authorization;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Grant\ClientException;
use Mockery as M;
@@ -17,7 +17,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
$_POST['grant_type'] = 'client_credentials';
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$server->addGrantType($grant);
@@ -34,7 +34,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
'client_id' => 'testapp'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$server->addGrantType($grant);
@@ -51,7 +51,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
'client_secret' => 'foobar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
@@ -75,13 +75,13 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
'scope' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -115,13 +115,13 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
'client_secret' => 'foobar'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -139,7 +139,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
// $scopeStorage->shouldReceive('get')->andReturn(
// // (new Scope($server))->setId('foo')
// // (new ScopeEntity($server))->setId('foo')
// );
$server->setClientStorage($clientStorage);
@@ -160,20 +160,20 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
'scope' => 'foo'
];
$server = new Authorization;
$server = new AuthorizationServer;
$grant = new ClientCredentials;
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$sessionStorage->shouldReceive('associateScope');
@@ -181,14 +181,14 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);

View File

@@ -5,6 +5,8 @@ namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\Password;
use League\OAuth2\Server\Grant\RefreshToken;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\AuthorizationServer;
use Mockery as M;
@@ -80,7 +82,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -123,7 +125,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -167,7 +169,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -212,7 +214,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -259,7 +261,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -309,14 +311,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$sessionStorage->shouldReceive('associateScope');
@@ -324,14 +326,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);
@@ -363,14 +365,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$sessionStorage->shouldReceive('associateScope');
@@ -378,14 +380,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);
@@ -422,14 +424,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');
$sessionStorage->shouldReceive('create')->andreturn(123);
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$sessionStorage->shouldReceive('associateScope');
@@ -437,14 +439,14 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');

View File

@@ -7,7 +7,7 @@ use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\RefreshToken as RT;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\AuthorizationServer;
use Mockery as M;
@@ -92,7 +92,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -127,7 +127,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$refreshTokenStorage = M::mock('League\OAuth2\Server\Storage\RefreshTokenInterface');
@@ -161,7 +161,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -169,18 +169,18 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$sessionStorage->shouldReceive('getScopes')->shouldReceive('getScopes')->andReturn([]);
$sessionStorage->shouldReceive('associateScope');
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
(new Session($server))
(new SessionEntity($server))
);
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
(new AccessToken($server))
(new AccessTokenEntity($server))
);
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
@@ -190,13 +190,13 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$refreshTokenStorage->shouldReceive('delete');
$refreshTokenStorage->shouldReceive('create');
$refreshTokenStorage->shouldReceive('get')->andReturn(
(new RT($server))
(new RefreshTokenEntity($server))
);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);
@@ -228,12 +228,12 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server = new AuthorizationServer;
$grant = new RefreshToken;
$oldSession = (new Session($server))->associateScope((new Scope($server))->setId('foo'));
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -247,12 +247,12 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
(new AccessToken($server))
(new AccessTokenEntity($server))
);
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
@@ -262,13 +262,13 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$refreshTokenStorage->shouldReceive('delete');
$refreshTokenStorage->shouldReceive('create');
$refreshTokenStorage->shouldReceive('get')->andReturn(
(new RT($server))
(new RefreshTokenEntity($server))
);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
);
$server->setClientStorage($clientStorage);
@@ -300,12 +300,12 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server = new AuthorizationServer;
$grant = new RefreshToken;
$oldSession = (new Session($server))->associateScope((new Scope($server))->setId('foo'));
$oldSession = (new SessionEntity($server))->associateScope((new ScopeEntity($server))->setId('foo'));
$clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface');
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
@@ -319,12 +319,12 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface');
$accessTokenStorage->shouldReceive('setServer');
$accessTokenStorage->shouldReceive('getByRefreshToken')->andReturn(
(new AccessToken($server))
(new AccessTokenEntity($server))
);
$accessTokenStorage->shouldReceive('delete');
$accessTokenStorage->shouldReceive('create');
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo')
(new ScopeEntity($server))->setId('foo')
]);
$accessTokenStorage->shouldReceive('associateScope');
@@ -334,13 +334,13 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$refreshTokenStorage->shouldReceive('delete');
$refreshTokenStorage->shouldReceive('create');
$refreshTokenStorage->shouldReceive('get')->andReturn(
(new RT($server))
(new RefreshTokenEntity($server))
);
$scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface');
$scopeStorage->shouldReceive('setServer');
$scopeStorage->shouldReceive('get')->andReturn(
(new Scope($server))->setId('blah')
(new ScopeEntity($server))->setId('blah')
);
$server->setClientStorage($clientStorage);

View File

@@ -139,20 +139,20 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
$server->setTokenKey('at');
$accessTokenStorage->shouldReceive('get')->andReturn(
(new AccessToken($server))->setToken('abcdef')
(new AccessTokenEntity($server))->setToken('abcdef')
);
$accessTokenStorage->shouldReceive('getScopes')->andReturn([
(new Scope($server))->setId('foo'),
(new Scope($server))->setId('bar')
(new ScopeEntity($server))->setId('foo'),
(new ScopeEntity($server))->setId('bar')
]);
$sessionStorage->shouldReceive('getByAccessToken')->andReturn(
(new Session($server))->setId('foobar')->setOwner('user', 123)
(new SessionEntity($server))->setId('foobar')->setOwner('user', 123)
);
$clientStorage->shouldReceive('getBySession')->andReturn(
(new Client($server))->setId('testapp')
(new ClientEntity($server))->setId('testapp')
);
$request = new \Symfony\Component\HttpFoundation\Request();