tests: use MockBuilder everywhere

This commit is contained in:
Lukáš Unger 2016-07-08 15:29:21 +02:00
parent 68e4b1d390
commit 32efd091a1
9 changed files with 92 additions and 91 deletions

View File

@ -29,9 +29,9 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
public function testRespondToRequestInvalidGrantType() public function testRespondToRequestInvalidGrantType()
{ {
$server = new AuthorizationServer( $server = new AuthorizationServer(
$this->getMock(ClientRepositoryInterface::class), $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(),
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/private.key', 'file://' . __DIR__ . '/Stubs/private.key',
'file://' . __DIR__ . '/Stubs/public.key', 'file://' . __DIR__ . '/Stubs/public.key',
new StubResponseType() new StubResponseType()
@ -49,13 +49,13 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
public function testRespondToRequest() public function testRespondToRequest()
{ {
$clientRepository = $this->getMock(ClientRepositoryInterface::class); $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity()); $clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(); $scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0); $scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
$accessTokenRepositoryMock = $this->getMock(AccessTokenRepositoryInterface::class); $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
$accessTokenRepositoryMock->method('getNewToken')->willReturn(new AccessTokenEntity()); $accessTokenRepositoryMock->method('getNewToken')->willReturn(new AccessTokenEntity());
$server = new AuthorizationServer( $server = new AuthorizationServer(
@ -78,12 +78,12 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
public function testGetResponseType() public function testGetResponseType()
{ {
$clientRepository = $this->getMock(ClientRepositoryInterface::class); $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$server = new AuthorizationServer( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/private.key', 'file://' . __DIR__ . '/Stubs/private.key',
'file://' . __DIR__ . '/Stubs/public.key' 'file://' . __DIR__ . '/Stubs/public.key'
); );
@ -97,12 +97,12 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
public function testCompleteAuthorizationRequest() public function testCompleteAuthorizationRequest()
{ {
$clientRepository = $this->getMock(ClientRepositoryInterface::class); $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$server = new AuthorizationServer( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/private.key', 'file://' . __DIR__ . '/Stubs/private.key',
'file://' . __DIR__ . '/Stubs/public.key' 'file://' . __DIR__ . '/Stubs/public.key'
); );
@ -112,7 +112,7 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -139,16 +139,16 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
$server = new AuthorizationServer( $server = new AuthorizationServer(
$clientRepositoryMock, $clientRepositoryMock,
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/private.key', 'file://' . __DIR__ . '/Stubs/private.key',
'file://' . __DIR__ . '/Stubs/public.key' 'file://' . __DIR__ . '/Stubs/public.key'
); );
@ -178,9 +178,9 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
public function testValidateAuthorizationRequestUnregistered() public function testValidateAuthorizationRequestUnregistered()
{ {
$server = new AuthorizationServer( $server = new AuthorizationServer(
$this->getMock(ClientRepositoryInterface::class), $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(),
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/private.key', 'file://' . __DIR__ . '/Stubs/private.key',
'file://' . __DIR__ . '/Stubs/public.key' 'file://' . __DIR__ . '/Stubs/public.key'
); );

View File

@ -326,7 +326,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
public function testIssueRefreshToken() public function testIssueRefreshToken()
{ {
$refreshTokenRepoMock = $this->getMock(RefreshTokenRepositoryInterface::class); $refreshTokenRepoMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
$refreshTokenRepoMock $refreshTokenRepoMock
->expects($this->once()) ->expects($this->once())
->method('getNewRefreshToken') ->method('getNewRefreshToken')
@ -350,7 +350,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
public function testIssueAccessToken() public function testIssueAccessToken()
{ {
$accessTokenRepoMock = $this->getMock(AccessTokenRepositoryInterface::class); $accessTokenRepoMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
$accessTokenRepoMock->method('getNewToken')->willReturn(new AccessTokenEntity()); $accessTokenRepoMock->method('getNewToken')->willReturn(new AccessTokenEntity());
/** @var AbstractGrant $grantMock */ /** @var AbstractGrant $grantMock */
@ -374,7 +374,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase
public function testIssueAuthCode() public function testIssueAuthCode()
{ {
$authCodeRepoMock = $this->getMock(AuthCodeRepositoryInterface::class); $authCodeRepoMock = $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock();
$authCodeRepoMock->expects($this->once())->method('getNewAuthCode')->willReturn(new AuthCodeEntity()); $authCodeRepoMock->expects($this->once())->method('getNewAuthCode')->willReturn(new AuthCodeEntity());
/** @var AbstractGrant $grantMock */ /** @var AbstractGrant $grantMock */

View File

@ -40,8 +40,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
public function testGetIdentifier() public function testGetIdentifier()
{ {
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -51,8 +51,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
public function testCanRespondToAuthorizationRequest() public function testCanRespondToAuthorizationRequest()
{ {
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -81,8 +81,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -113,8 +113,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -146,8 +146,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -181,8 +181,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -213,8 +213,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn(null); $clientRepositoryMock->method('getClientEntity')->willReturn(null);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -248,8 +248,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -284,8 +284,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -320,8 +320,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -357,8 +357,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -397,7 +397,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -424,7 +424,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -456,8 +456,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -524,8 +524,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -596,8 +596,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -657,8 +657,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(); $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -700,8 +700,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(); $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -746,8 +746,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf(); $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -811,7 +811,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepositoryMock, $authCodeRepositoryMock,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -871,8 +871,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf(); $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -932,8 +932,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf(); $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willReturnSelf();
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -989,8 +989,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -1062,8 +1062,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -1135,8 +1135,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->enableCodeExchangeProof(); $grant->enableCodeExchangeProof();
@ -1201,7 +1201,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -1229,7 +1229,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -1257,7 +1257,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$authCodeRepository, $authCodeRepository,
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
@ -1290,8 +1290,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->expects($this->at(1))->method('persistNewRefreshToken'); $refreshTokenRepositoryMock->expects($this->at(1))->method('persistNewRefreshToken');
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -1362,8 +1362,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willThrowException(OAuthServerException::serverError('something bad happened')); $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willThrowException(OAuthServerException::serverError('something bad happened'));
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);
@ -1434,8 +1434,8 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
$refreshTokenRepositoryMock->method('persistNewRefreshToken')->willThrowException(UniqueTokenIdentifierConstraintViolationException::create()); $refreshTokenRepositoryMock->method('persistNewRefreshToken')->willThrowException(UniqueTokenIdentifierConstraintViolationException::create());
$grant = new AuthCodeGrant( $grant = new AuthCodeGrant(
$this->getMock(AuthCodeRepositoryInterface::class), $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
$this->getMock(RefreshTokenRepositoryInterface::class), $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
new \DateInterval('PT10M') new \DateInterval('PT10M')
); );
$grant->setClientRepository($clientRepositoryMock); $grant->setClientRepository($clientRepositoryMock);

View File

@ -8,6 +8,7 @@ use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationExcep
use League\OAuth2\Server\Grant\ImplicitGrant; use League\OAuth2\Server\Grant\ImplicitGrant;
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
use League\OAuth2\Server\RequestTypes\AuthorizationRequest; use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
use League\OAuth2\Server\ResponseTypes\RedirectResponse; use League\OAuth2\Server\ResponseTypes\RedirectResponse;
use LeagueTests\Stubs\AccessTokenEntity; use LeagueTests\Stubs\AccessTokenEntity;

View File

@ -21,8 +21,8 @@ class PasswordGrantTest extends \PHPUnit_Framework_TestCase
{ {
public function testGetIdentifier() public function testGetIdentifier()
{ {
$userRepositoryMock = $this->getMock(UserRepositoryInterface::class); $userRepositoryMock = $this->getMockBuilder(UserRepositoryInterface::class)->getMock();
$refreshTokenRepositoryMock = $this->getMock(RefreshTokenRepositoryInterface::class); $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
$grant = new PasswordGrant($userRepositoryMock, $refreshTokenRepositoryMock); $grant = new PasswordGrant($userRepositoryMock, $refreshTokenRepositoryMock);
$this->assertEquals('password', $grant->getIdentifier()); $this->assertEquals('password', $grant->getIdentifier());

View File

@ -32,7 +32,7 @@ class RefreshTokenGrantTest extends \PHPUnit_Framework_TestCase
public function testGetIdentifier() public function testGetIdentifier()
{ {
$refreshTokenRepositoryMock = $this->getMock(RefreshTokenRepositoryInterface::class); $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock();
$grant = new RefreshTokenGrant($refreshTokenRepositoryMock); $grant = new RefreshTokenGrant($refreshTokenRepositoryMock);
$this->assertEquals('refresh_token', $grant->getIdentifier()); $this->assertEquals('refresh_token', $grant->getIdentifier());

View File

@ -19,13 +19,13 @@ class AuthorizationServerMiddlewareTest extends \PHPUnit_Framework_TestCase
{ {
public function testValidResponse() public function testValidResponse()
{ {
$clientRepository = $this->getMock(ClientRepositoryInterface::class); $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepository->method('getClientEntity')->willReturn(new ClientEntity()); $clientRepository->method('getClientEntity')->willReturn(new ClientEntity());
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(); $scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0); $scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
$accessRepositoryMock = $this->getMock(AccessTokenRepositoryInterface::class); $accessRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
$accessRepositoryMock->method('getNewToken')->willReturn(new AccessTokenEntity()); $accessRepositoryMock->method('getNewToken')->willReturn(new AccessTokenEntity());
$server = new AuthorizationServer( $server = new AuthorizationServer(
@ -58,13 +58,13 @@ class AuthorizationServerMiddlewareTest extends \PHPUnit_Framework_TestCase
public function testOAuthErrorResponse() public function testOAuthErrorResponse()
{ {
$clientRepository = $this->getMock(ClientRepositoryInterface::class); $clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepository->method('getClientEntity')->willReturn(null); $clientRepository->method('getClientEntity')->willReturn(null);
$server = new AuthorizationServer( $server = new AuthorizationServer(
$clientRepository, $clientRepository,
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
$this->getMock(ScopeRepositoryInterface::class), $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/../Stubs/private.key', 'file://' . __DIR__ . '/../Stubs/private.key',
'file://' . __DIR__ . '/../Stubs/public.key', 'file://' . __DIR__ . '/../Stubs/public.key',
new StubResponseType() new StubResponseType()

View File

@ -16,7 +16,7 @@ class ResourceServerMiddlewareTest extends \PHPUnit_Framework_TestCase
public function testValidResponse() public function testValidResponse()
{ {
$server = new ResourceServer( $server = new ResourceServer(
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/../Stubs/public.key' 'file://' . __DIR__ . '/../Stubs/public.key'
); );
@ -51,7 +51,7 @@ class ResourceServerMiddlewareTest extends \PHPUnit_Framework_TestCase
public function testValidResponseExpiredToken() public function testValidResponseExpiredToken()
{ {
$server = new ResourceServer( $server = new ResourceServer(
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/../Stubs/public.key' 'file://' . __DIR__ . '/../Stubs/public.key'
); );
@ -86,7 +86,7 @@ class ResourceServerMiddlewareTest extends \PHPUnit_Framework_TestCase
public function testErrorResponse() public function testErrorResponse()
{ {
$server = new ResourceServer( $server = new ResourceServer(
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/../Stubs/public.key' 'file://' . __DIR__ . '/../Stubs/public.key'
); );

View File

@ -13,7 +13,7 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
public function testValidateAuthenticatedRequest() public function testValidateAuthenticatedRequest()
{ {
$server = new ResourceServer( $server = new ResourceServer(
$this->getMock(AccessTokenRepositoryInterface::class), $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
'file://' . __DIR__ . '/Stubs/public.key' 'file://' . __DIR__ . '/Stubs/public.key'
); );