diff options
Diffstat (limited to 'Http')
31 files changed, 316 insertions, 316 deletions
diff --git a/Http/Tests/AccessMapTest.php b/Http/Tests/AccessMapTest.php index d8ab7aa..b71ad85 100644 --- a/Http/Tests/AccessMapTest.php +++ b/Http/Tests/AccessMapTest.php @@ -17,7 +17,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase { public function testReturnsFirstMatchedPattern() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $requestMatcher1 = $this->getRequestMatcher($request, false); $requestMatcher2 = $this->getRequestMatcher($request, true); @@ -30,7 +30,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase public function testReturnsEmptyPatternIfNoneMatched() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $requestMatcher = $this->getRequestMatcher($request, false); $map = new AccessMap(); @@ -41,7 +41,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase private function getRequestMatcher($request, $matches) { - $requestMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcherInterface'); + $requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock(); $requestMatcher->expects($this->once()) ->method('matches')->with($request) ->will($this->returnValue($matches)); diff --git a/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php b/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php index 252b124..da30aa9 100644 --- a/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php +++ b/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php @@ -32,14 +32,14 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas protected function setUp() { - $this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); + $this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session)); - $this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException', array('getMessage')); + $this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(array('getMessage'))->getMock(); } public function testForward() @@ -173,8 +173,8 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas private function getRequest() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $request->attributes = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock(); return $request; } diff --git a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php index ae9f02b..7166c53 100644 --- a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -24,10 +24,10 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas protected function setUp() { - $this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->request->headers = $this->getMock('Symfony\Component\HttpFoundation\HeaderBag'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->request->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\HeaderBag')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } public function testRequestIsRedirected() @@ -87,7 +87,7 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas public function testTargetPathIsTakenFromTheSession() { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once()) ->method('get')->with('_security.admin.target_path') ->will($this->returnValue('/admin/dashboard')); diff --git a/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php index 8a31886..330b21a 100644 --- a/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ b/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php @@ -34,11 +34,11 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface'); - $this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface'); + $this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(); + $this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); // No methods are invoked on the exception; we just assert on its class $this->authenticationException = new AuthenticationException(); @@ -47,7 +47,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler() { - $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $this->successHandler->expects($this->once()) ->method('onAuthenticationSuccess') @@ -117,7 +117,7 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler() { - $authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface'); + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $this->failureHandler->expects($this->once()) ->method('onAuthenticationFailure') diff --git a/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php b/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php index ca5922c..359c6de 100644 --- a/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php +++ b/Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php @@ -18,7 +18,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $authException = new AuthenticationException('The exception message'); @@ -31,7 +31,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase public function testStartWithoutAuthException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $entryPoint = new BasicAuthenticationEntryPoint('TheRealmName'); diff --git a/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php b/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php index 181e340..a3e0352 100644 --- a/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php +++ b/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php @@ -19,7 +19,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $authenticationException = new AuthenticationException('TheAuthenticationExceptionMessage'); @@ -32,7 +32,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase public function testStartWithNoException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheKey'); $response = $entryPoint->start($request); @@ -43,7 +43,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase public function testStartWithNonceExpiredException() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $nonceExpiredException = new NonceExpiredException('TheNonceExpiredExceptionMessage'); diff --git a/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php b/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php index 75a6be4..0247e5f 100644 --- a/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php +++ b/Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php @@ -19,11 +19,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { public function testStart() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new Response(); - $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->once()) ->method('createRedirectResponse') @@ -38,11 +38,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase public function testStartWithUseForward() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); - $subRequest = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); + $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $response = new Response('', 200); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils ->expects($this->once()) ->method('createRequest') @@ -50,7 +50,7 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($subRequest)) ; - $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $httpKernel ->expects($this->once()) ->method('handle') diff --git a/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php index 61f086a..fa8a583 100644 --- a/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -24,9 +24,9 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), array()); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -38,7 +38,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -56,7 +56,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -72,7 +72,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -84,7 +84,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -102,7 +102,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -120,7 +120,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -132,7 +132,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -150,7 +150,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -168,14 +168,14 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -191,7 +191,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -209,7 +209,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase $token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -222,7 +222,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ; $exception = new AuthenticationException('Authentication failed.'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -240,7 +240,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase ->method('getPreAuthenticatedData') ->will($this->returnValue($userCredentials)); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/Http/Tests/Firewall/AccessListenerTest.php b/Http/Tests/Firewall/AccessListenerTest.php index af9d565..7f8ecea 100644 --- a/Http/Tests/Firewall/AccessListenerTest.php +++ b/Http/Tests/Firewall/AccessListenerTest.php @@ -20,9 +20,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase */ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -30,21 +30,21 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array('foo' => 'bar'), null))) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(true)) ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -56,10 +56,10 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase $tokenStorage, $accessDecisionManager, $accessMap, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -71,9 +71,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase public function testHandleWhenTheTokenIsNotAuthenticated() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -81,21 +81,21 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array('foo' => 'bar'), null))) ; - $notAuthenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $notAuthenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $notAuthenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(false)) ; - $authenticatedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $authenticatedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $authenticatedToken ->expects($this->any()) ->method('isAuthenticated') ->will($this->returnValue(true)) ; - $authManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authManager ->expects($this->once()) ->method('authenticate') @@ -103,7 +103,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($authenticatedToken)) ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -115,7 +115,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($authenticatedToken)) ; - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); $accessDecisionManager ->expects($this->once()) ->method('decide') @@ -130,7 +130,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase $authManager ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -142,9 +142,9 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -152,13 +152,13 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(null, null))) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->never()) ->method('isAuthenticated') ; - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -167,12 +167,12 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase $listener = new AccessListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), $accessMap, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -187,7 +187,7 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase */ public function testHandleWhenTheSecurityTokenStorageHasNoToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -196,12 +196,12 @@ class AccessListenerTest extends \PHPUnit_Framework_TestCase $listener = new AccessListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'), - $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'), - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface') + $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $listener->handle($event); } diff --git a/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php b/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php index 3450c1e..c5761ac 100644 --- a/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php @@ -18,30 +18,30 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase { public function testHandleWithTokenStorageHavingAToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $tokenStorage ->expects($this->never()) ->method('setToken') ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandleWithTokenStorageHavingNoToken() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -50,7 +50,7 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $anonymousToken = new AnonymousToken('TheKey', 'anon.', array()); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -67,21 +67,21 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ; $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', null, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } public function testHandledEventIsLogged() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $logger = $this->getMock('Psr\Log\LoggerInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); $logger->expects($this->once()) ->method('info') ->with('Populated the TokenStorage with an anonymous Token.') ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheKey', $logger, $authenticationManager); - $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); + $listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock()); } } diff --git a/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/Http/Tests/Firewall/BasicAuthenticationListenerTest.php index 8901cb2..62c23f6 100644 --- a/Http/Tests/Firewall/BasicAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/BasicAuthenticationListenerTest.php @@ -27,9 +27,9 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase 'PHP_AUTH_PW' => 'ThePassword', )); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -41,7 +41,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->once()) ->method('authenticate') @@ -53,10 +53,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -73,9 +73,9 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase 'PHP_AUTH_PW' => 'ThePassword', )); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -88,7 +88,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $response = new Response(); - $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') @@ -98,12 +98,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))), + new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())), 'TheProviderKey', $authenticationEntryPoint ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -122,7 +122,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase { $request = new Request(); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->never()) ->method('getToken') @@ -130,12 +130,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $listener = new BasicAuthenticationListener( $tokenStorage, - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -151,14 +151,14 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $token = new UsernamePasswordToken('TheUsername', 'ThePassword', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') ->will($this->returnValue($token)) ; - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $authenticationManager ->expects($this->never()) ->method('authenticate') @@ -168,10 +168,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $tokenStorage, $authenticationManager, 'TheProviderKey', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -188,10 +188,10 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase public function testItRequiresProviderKey() { new BasicAuthenticationListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), - $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(), '', - $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface') + $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock() ); } @@ -204,7 +204,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage ->expects($this->any()) ->method('getToken') @@ -217,7 +217,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $response = new Response(); - $authenticationEntryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $authenticationEntryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $authenticationEntryPoint ->expects($this->any()) ->method('start') @@ -227,12 +227,12 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $listener = new BasicAuthenticationListener( $tokenStorage, - new AuthenticationProviderManager(array($this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface'))), + new AuthenticationProviderManager(array($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock())), 'TheProviderKey', $authenticationEntryPoint ); - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/Http/Tests/Firewall/ChannelListenerTest.php b/Http/Tests/Firewall/ChannelListenerTest.php index 1465224..ae6c39f 100644 --- a/Http/Tests/Firewall/ChannelListenerTest.php +++ b/Http/Tests/Firewall/ChannelListenerTest.php @@ -18,14 +18,14 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase { public function testHandleWithNotSecuredRequestAndHttpChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->will($this->returnValue(false)) ; - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -33,13 +33,13 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array(), 'http'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->never()) ->method('start') ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -56,14 +56,14 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase public function testHandleWithSecuredRequestAndHttpsChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') ->will($this->returnValue(true)) ; - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -71,13 +71,13 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array(), 'https'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->never()) ->method('start') ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -94,7 +94,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase public function testHandleWithNotSecuredRequestAndHttpsChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -103,7 +103,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase $response = new Response(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -111,7 +111,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array(), 'https'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->once()) ->method('start') @@ -119,7 +119,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($response)) ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') @@ -137,7 +137,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase public function testHandleWithSecuredRequestAndHttpChannel() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $request ->expects($this->any()) ->method('isSecure') @@ -146,7 +146,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase $response = new Response(); - $accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface'); + $accessMap = $this->getMockBuilder('Symfony\Component\Security\Http\AccessMapInterface')->getMock(); $accessMap ->expects($this->any()) ->method('getPatterns') @@ -154,7 +154,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array(), 'http'))) ; - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint ->expects($this->once()) ->method('start') @@ -162,7 +162,7 @@ class ChannelListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($response)) ; - $event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $event ->expects($this->any()) ->method('getRequest') diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php index ae1199a..5453b31 100644 --- a/Http/Tests/Firewall/ContextListenerTest.php +++ b/Http/Tests/Firewall/ContextListenerTest.php @@ -32,7 +32,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testItRequiresContextKey() { new ContextListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), array(), '' ); @@ -45,7 +45,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testUserProvidersNeedToImplementAnInterface() { new ContextListener( - $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), array(new \stdClass()), 'key123' ); @@ -94,7 +94,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $request->setSession($session); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() @@ -113,7 +113,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $request->setSession($session); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() @@ -130,12 +130,12 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase */ public function testInvalidTokenInSession($token) { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $event->expects($this->any()) ->method('getRequest') @@ -169,8 +169,8 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testHandleAddsKernelResponseListener() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->disableOriginalConstructor() ->getMock(); @@ -182,7 +182,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $event->expects($this->any()) ->method('getRequest') - ->will($this->returnValue($this->getMock('Symfony\Component\HttpFoundation\Request'))); + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock())); $dispatcher->expects($this->once()) ->method('addListener') @@ -193,15 +193,15 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testOnKernelResponseListenerRemovesItself() { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent') ->disableOriginalConstructor() ->getMock(); $listener = new ContextListener($tokenStorage, array(), 'key123', null, $dispatcher); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any()) ->method('hasSession') ->will($this->returnValue(true)); @@ -222,7 +222,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase public function testHandleRemovesTokenIfNoPreviousSessionWasFound() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $request->expects($this->any())->method('hasPreviousSession')->will($this->returnValue(false)); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') @@ -230,7 +230,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase ->getMock(); $event->expects($this->any())->method('getRequest')->will($this->returnValue($request)); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $tokenStorage->expects($this->once())->method('setToken')->with(null); $listener = new ContextListener($tokenStorage, array(), 'key123'); @@ -253,7 +253,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase $request->cookies->set('MOCKSESSID', true); $event = new FilterResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST, new Response() diff --git a/Http/Tests/Firewall/ExceptionListenerTest.php b/Http/Tests/Firewall/ExceptionListenerTest.php index 3d409e5..b372447 100644 --- a/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/Http/Tests/Firewall/ExceptionListenerTest.php @@ -84,12 +84,12 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase */ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); $event = $this->createEvent($exception, $kernel); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error'))); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), $httpUtils, null, '/error'); @@ -106,7 +106,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase { $event = $this->createEvent($exception); - $accessDeniedHandler = $this->getMock('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface'); + $accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock(); $accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error'))); $listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler); @@ -123,8 +123,8 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase { $event = $this->createEvent($exception); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())); $listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint()); $listener->onKernelException($event); @@ -146,7 +146,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createEntryPoint() { - $entryPoint = $this->getMock('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface'); + $entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock(); $entryPoint->expects($this->once())->method('start')->will($this->returnValue(new Response('OK'))); return $entryPoint; @@ -154,7 +154,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createTrustResolver($fullFledged) { - $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'); + $trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(); $trustResolver->expects($this->once())->method('isFullFledged')->will($this->returnValue($fullFledged)); return $trustResolver; @@ -163,7 +163,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createEvent(\Exception $exception, $kernel = null) { if (null === $kernel) { - $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); } return new GetResponseForExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $exception); @@ -172,9 +172,9 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase private function createExceptionListener(TokenStorageInterface $tokenStorage = null, AuthenticationTrustResolverInterface $trustResolver = null, HttpUtils $httpUtils = null, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null) { return new ExceptionListener( - $tokenStorage ?: $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'), - $trustResolver ?: $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'), - $httpUtils ?: $this->getMock('Symfony\Component\Security\Http\HttpUtils'), + $tokenStorage ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(), + $trustResolver ?: $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock(), + $httpUtils ?: $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(), 'key', $authenticationEntryPoint, $errorPage, diff --git a/Http/Tests/Firewall/LogoutListenerTest.php b/Http/Tests/Firewall/LogoutListenerTest.php index 15c996e..0cc4706 100644 --- a/Http/Tests/Firewall/LogoutListenerTest.php +++ b/Http/Tests/Firewall/LogoutListenerTest.php @@ -172,12 +172,12 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase private function getTokenManager() { - return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock(); } private function getTokenStorage() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); } private function getGetResponseEvent() @@ -195,7 +195,7 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase private function getHandler() { - return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutHandlerInterface')->getMock(); } private function getHttpUtils() @@ -225,11 +225,11 @@ class LogoutListenerTest extends \PHPUnit_Framework_TestCase private function getSuccessHandler() { - return $this->getMock('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface')->getMock(); } private function getToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } } diff --git a/Http/Tests/Firewall/RememberMeListenerTest.php b/Http/Tests/Firewall/RememberMeListenerTest.php index cd2f1b8..141b4cc 100644 --- a/Http/Tests/Firewall/RememberMeListenerTest.php +++ b/Http/Tests/Firewall/RememberMeListenerTest.php @@ -25,7 +25,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase $tokenStorage ->expects($this->once()) ->method('getToken') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $tokenStorage @@ -75,7 +75,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $service @@ -117,7 +117,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase $service ->expects($this->once()) ->method('autoLogin') - ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock())) ; $service @@ -152,7 +152,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -191,7 +191,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -210,14 +210,14 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($token)) ; - $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') ->will($this->returnValue(true)) ; - $request = $this->getMock('\Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->once()) ->method('hasSession') @@ -256,7 +256,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -275,7 +275,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($token)) ; - $session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session ->expects($this->once()) ->method('isStarted') @@ -286,7 +286,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->method('migrate') ; - $request = $this->getMock('\Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Request')->getMock(); $request ->expects($this->any()) ->method('hasSession') @@ -319,7 +319,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(null)) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service ->expects($this->once()) ->method('autoLogin') @@ -360,12 +360,12 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase protected function getGetResponseEvent() { - return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); } protected function getFilterResponseEvent() { - return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false); + return $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FilterResponseEvent')->disableOriginalConstructor()->getMock(); } protected function getListener($withDispatcher = false, $catchExceptions = true, $withSessionStrategy = false) @@ -385,31 +385,31 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase protected function getLogger() { - return $this->getMock('Psr\Log\LoggerInterface'); + return $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); } protected function getManager() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); } protected function getService() { - return $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock(); } protected function getTokenStorage() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); } protected function getDispatcher() { - return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + return $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); } private function getSessionStrategy() { - return $this->getMock('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface'); + return $this->getMockBuilder('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock(); } } diff --git a/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php b/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php index dad7aad..985152c 100644 --- a/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php @@ -24,9 +24,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), $serverVars); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -48,9 +48,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase { $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, @@ -71,9 +71,9 @@ class RemoteUserAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), array( 'TheUserKey' => 'TheUser', )); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, diff --git a/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php index 0a1286c..6061b12 100644 --- a/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php @@ -42,7 +42,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->token)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -79,7 +79,7 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo(null)) ; - $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface'); + $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface')->getMock(); $simpleAuthenticator ->expects($this->once()) ->method('createToken') @@ -99,20 +99,20 @@ class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase ->getMock() ; - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $this->request = new Request(array(), array(), array(), array(), array(), array()); - $this->event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false); + $this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock(); $this->event ->expects($this->any()) ->method('getRequest') ->will($this->returnValue($this->request)) ; - $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } protected function tearDown() diff --git a/Http/Tests/Firewall/SwitchUserListenerTest.php b/Http/Tests/Firewall/SwitchUserListenerTest.php index 28d73e0..b80f8c6 100644 --- a/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -31,13 +31,13 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); - $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); - $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); - $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $this->request->query = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag'); - $this->request->server = $this->getMock('Symfony\Component\HttpFoundation\ServerBag'); + $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); + $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); + $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock(); + $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); + $this->request->query = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock(); + $this->request->server = $this->getMockBuilder('Symfony\Component\HttpFoundation\ServerBag')->getMock(); $this->event = $this->getEvent($this->request); } @@ -66,7 +66,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase */ public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); $this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('_exit')); @@ -104,8 +104,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase public function testExitUserDispatchesEventWithRefreshedUser() { - $originalUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $refreshedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $originalUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $refreshedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $this ->userProvider ->expects($this->any()) @@ -145,7 +145,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase ->method('all') ->will($this->returnValue(array())); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher ->expects($this->once()) ->method('dispatch') @@ -201,7 +201,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase ->method('getUri') ->willReturn('/'); - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $dispatcher ->expects($this->never()) ->method('dispatch') @@ -216,7 +216,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase */ public function testSwitchUserIsDisallowed() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); $this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba')); @@ -231,8 +231,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase public function testSwitchUser() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->any())->method('getRoles')->will($this->returnValue(array())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); @@ -261,8 +261,8 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase public function testSwitchUserKeepsOtherQueryStringParameters() { - $token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface'))); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getToken(array($this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleInterface')->getMock())); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user->expects($this->any())->method('getRoles')->will($this->returnValue(array())); $this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token)); @@ -303,7 +303,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase private function getToken(array $roles = array()) { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token->expects($this->any()) ->method('getRoles') ->will($this->returnValue($roles)); diff --git a/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/Http/Tests/Firewall/X509AuthenticationListenerTest.php index 66690d9..3e58e69 100644 --- a/Http/Tests/Firewall/X509AuthenticationListenerTest.php +++ b/Http/Tests/Firewall/X509AuthenticationListenerTest.php @@ -31,9 +31,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase $request = new Request(array(), array(), array(), array(), array(), $serverVars); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -60,9 +60,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress; $request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials)); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -88,9 +88,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase { $request = new Request(array(), array(), array(), array(), array(), array()); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey'); @@ -108,9 +108,9 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase 'TheUserKey' => 'TheUser', 'TheCredentialsKey' => 'TheCredentials', )); - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new X509AuthenticationListener($tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey'); diff --git a/Http/Tests/FirewallMapTest.php b/Http/Tests/FirewallMapTest.php index 85a57ab..016c72d 100644 --- a/Http/Tests/FirewallMapTest.php +++ b/Http/Tests/FirewallMapTest.php @@ -22,7 +22,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -30,27 +30,27 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); - $matchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $matchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $matchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(true)) ; - $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); - $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); + $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add($matchingMatcher, array($theListener), $theException); - $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; - $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); @@ -64,7 +64,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -72,20 +72,20 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); - $theListener = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); - $theException = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); + $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add(null, array($theListener), $theException); - $tooLateMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; - $map->add($tooLateMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); @@ -99,7 +99,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase $request = new Request(); - $notMatchingMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcher'); + $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') @@ -107,7 +107,7 @@ class FirewallMapTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(false)) ; - $map->add($notMatchingMatcher, array($this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'))); + $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); diff --git a/Http/Tests/FirewallTest.php b/Http/Tests/FirewallTest.php index 1e0c1ef..20da3ae 100644 --- a/Http/Tests/FirewallTest.php +++ b/Http/Tests/FirewallTest.php @@ -20,18 +20,18 @@ class FirewallTest extends \PHPUnit_Framework_TestCase { public function testOnKernelRequestRegistersExceptionListener() { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $listener = $this->getMock('Symfony\Component\Security\Http\Firewall\ExceptionListener', array(), array(), '', false); + $listener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $listener ->expects($this->once()) ->method('register') ->with($this->equalTo($dispatcher)) ; - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') @@ -39,7 +39,7 @@ class FirewallTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(array(), $listener))) ; - $event = new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); + $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $firewall = new Firewall($map, $dispatcher); $firewall->onKernelRequest($event); @@ -49,59 +49,59 @@ class FirewallTest extends \PHPUnit_Framework_TestCase { $response = new Response(); - $first = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); + $first = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $first ->expects($this->once()) ->method('handle') ; - $second = $this->getMock('Symfony\Component\Security\Http\Firewall\ListenerInterface'); + $second = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $second ->expects($this->never()) ->method('handle') ; - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') ->will($this->returnValue(array(array($first, $second), null))) ; - $event = $this->getMock( - 'Symfony\Component\HttpKernel\Event\GetResponseEvent', - array('hasResponse'), - array( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), - $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false), + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->setMethods(array('hasResponse')) + ->setConstructorArgs(array( + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(), HttpKernelInterface::MASTER_REQUEST, - ) - ); + )) + ->getMock() + ; $event ->expects($this->once()) ->method('hasResponse') ->will($this->returnValue(true)) ; - $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface')); + $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); } public function testOnKernelRequestWithSubRequest() { - $map = $this->getMock('Symfony\Component\Security\Http\FirewallMapInterface'); + $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->never()) ->method('getListeners') ; $event = new GetResponseEvent( - $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), - $this->getMock('Symfony\Component\HttpFoundation\Request'), + $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), + $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(), HttpKernelInterface::SUB_REQUEST ); - $firewall = new Firewall($map, $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface')); + $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); $this->assertFalse($event->hasResponse()); diff --git a/Http/Tests/HttpUtilsTest.php b/Http/Tests/HttpUtilsTest.php index 45a0281..bb432a0 100644 --- a/Http/Tests/HttpUtilsTest.php +++ b/Http/Tests/HttpUtilsTest.php @@ -39,7 +39,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCreateRedirectResponseWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $urlGenerator ->expects($this->any()) @@ -50,7 +50,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) ; $response = $utils->createRedirectResponse($this->getRequest(), 'foobar'); @@ -73,7 +73,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCreateRequestWithRouteName() { - $utils = new HttpUtils($urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $urlGenerator ->expects($this->once()) @@ -83,7 +83,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase $urlGenerator ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))) + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())) ; $subRequest = $utils->createRequest($this->getRequest(), 'foobar'); @@ -93,7 +93,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCreateRequestWithAbsoluteUrl() { - $utils = new HttpUtils($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')); + $utils = new HttpUtils($this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock()); $subRequest = $utils->createRequest($this->getRequest(), 'http://symfony.com/'); $this->assertEquals('/', $subRequest->getPathInfo()); @@ -102,7 +102,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCreateRequestPassesSessionToTheNewRequest() { $request = $this->getRequest(); - $request->setSession($session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface')); + $request->setSession($session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock()); $utils = new HttpUtils($this->getUrlGenerator()); $subRequest = $utils->createRequest($request, '/foobar'); @@ -148,7 +148,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCheckRequestPathWithUrlMatcherAndResourceNotFound() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -163,7 +163,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCheckRequestPathWithUrlMatcherAndMethodNotAllowed() { $request = $this->getRequest(); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -177,7 +177,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCheckRequestPathWithUrlMatcherAndResourceFoundByUrl() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -192,7 +192,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase public function testCheckRequestPathWithUrlMatcherAndResourceFoundByRequest() { $request = $this->getRequest(); - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('matchRequest') @@ -209,7 +209,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase */ public function testCheckRequestPathWithUrlMatcherLoadingException() { - $urlMatcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $urlMatcher ->expects($this->any()) ->method('match') @@ -250,7 +250,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase private function getUrlGenerator($generatedUrl = '/foo/bar') { - $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock(); $urlGenerator ->expects($this->any()) ->method('generate') diff --git a/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php b/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php index 8474504..300f28d 100644 --- a/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php +++ b/Http/Tests/Logout/CookieClearingLogoutHandlerTest.php @@ -22,7 +22,7 @@ class CookieClearingLogoutHandlerTest extends \PHPUnit_Framework_TestCase { $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $handler = new CookieClearingLogoutHandler(array('foo' => array('path' => '/foo', 'domain' => 'foo.foo'), 'foo2' => array('path' => null, 'domain' => null))); diff --git a/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php b/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php index 8a94e53..7f20f67 100644 --- a/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php +++ b/Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php @@ -18,10 +18,10 @@ class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase { public function testLogout() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $response = new Response(); - $httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils'); + $httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock(); $httpUtils->expects($this->once()) ->method('createRedirectResponse') ->with($request, '/dashboard') diff --git a/Http/Tests/Logout/SessionLogoutHandlerTest.php b/Http/Tests/Logout/SessionLogoutHandlerTest.php index c342995..6a435d7 100644 --- a/Http/Tests/Logout/SessionLogoutHandlerTest.php +++ b/Http/Tests/Logout/SessionLogoutHandlerTest.php @@ -20,9 +20,9 @@ class SessionLogoutHandlerTest extends \PHPUnit_Framework_TestCase { $handler = new SessionLogoutHandler(); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); $response = new Response(); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session', array(), array(), '', false); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock(); $request ->expects($this->once()) @@ -35,6 +35,6 @@ class SessionLogoutHandlerTest extends \PHPUnit_Framework_TestCase ->method('invalidate') ; - $handler->logout($request, $response, $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $handler->logout($request, $response, $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); } } diff --git a/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index ddfaaeb..259214c 100644 --- a/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -62,7 +62,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $request->cookies->set('foo', 'foo'); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -90,7 +90,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, $options); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service->logout($request, $response, $token); $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); $this->assertInstanceOf('Symfony\Component\HttpFoundation\Cookie', $cookie); @@ -125,8 +125,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -148,8 +148,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -172,8 +172,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -199,8 +199,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $request->request->set('foo', array('bar' => $value)); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -226,8 +226,8 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $request->request->set('foo', $value); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -290,7 +290,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index f43963e..d7b55da 100644 --- a/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -61,7 +61,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $tokenValue = 'foovalue', ))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -80,7 +80,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -105,7 +105,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $service->setTokenProvider($tokenProvider); $tokenProvider @@ -136,7 +136,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -151,7 +151,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test public function testAutoLogin() { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -170,7 +170,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('loadTokenBySeries') @@ -193,9 +193,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('deleteTokenBySeries') @@ -219,9 +219,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -242,9 +242,9 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $request->cookies->set('foo', 'somefoovalue'); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->never()) ->method('deleteTokenBySeries') @@ -272,20 +272,20 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test $request = new Request(); $response = new Response(); - $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $account ->expects($this->once()) ->method('getUsername') ->will($this->returnValue('foo')) ; - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->any()) ->method('getUser') ->will($this->returnValue($account)) ; - $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); + $tokenProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface')->getMock(); $tokenProvider ->expects($this->once()) ->method('createNewToken') @@ -327,7 +327,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/Http/Tests/RememberMe/ResponseListenerTest.php b/Http/Tests/RememberMe/ResponseListenerTest.php index 23f7df7..0db86e7 100644 --- a/Http/Tests/RememberMe/ResponseListenerTest.php +++ b/Http/Tests/RememberMe/ResponseListenerTest.php @@ -83,7 +83,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase private function getResponse() { $response = new Response(); - $response->headers = $this->getMock('Symfony\Component\HttpFoundation\ResponseHeaderBag'); + $response->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->getMock(); return $response; } diff --git a/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index e3b58e9..5588257 100644 --- a/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -62,7 +62,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash')); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -87,7 +87,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass')); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -112,7 +112,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase */ public function testAutoLogin($username) { - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getRoles') @@ -156,7 +156,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'secure' => true, 'httponly' => false)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $service->logout($request, $response, $token); @@ -186,7 +186,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); $token ->expects($this->once()) ->method('getUser') @@ -208,8 +208,8 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase $request = new Request(); $response = new Response(); - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user ->expects($this->once()) ->method('getPassword') @@ -272,7 +272,7 @@ class TokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase protected function getProvider() { - $provider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface'); + $provider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); $provider ->expects($this->any()) ->method('supportsClass') diff --git a/Http/Tests/Session/SessionAuthenticationStrategyTest.php b/Http/Tests/Session/SessionAuthenticationStrategyTest.php index 4aef4b2..c23821a 100644 --- a/Http/Tests/Session/SessionAuthenticationStrategyTest.php +++ b/Http/Tests/Session/SessionAuthenticationStrategyTest.php @@ -43,7 +43,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('We cannot destroy the old session on PHP 5.4.0 - 5.4.10.'); } - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('migrate')->with($this->equalTo(true)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); @@ -56,7 +56,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('This PHP version is not affected.'); } - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('migrate')->with($this->equalTo(false)); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); @@ -65,7 +65,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase public function testSessionIsInvalidated() { - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock(); $session->expects($this->once())->method('invalidate'); $strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::INVALIDATE); @@ -74,7 +74,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase private function getRequest($session = null) { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); if (null !== $session) { $request->expects($this->any())->method('getSession')->will($this->returnValue($session)); @@ -85,6 +85,6 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase private function getToken() { - return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); } } |