summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-12-19 16:53:49 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2016-12-19 16:53:49 +0100
commita57c25800dcd39387a9a831ef8f436a6bebb8e72 (patch)
tree536a2ddb082b1cd251fdc04ff8d9e5700593f805
parent05b01b879902a75c64b610a28d1f0dc0bee58c91 (diff)
parent674b38ff1ae98e993fd18e599120ead43705c4bc (diff)
downloadsymfony-security-a57c25800dcd39387a9a831ef8f436a6bebb8e72.zip
symfony-security-a57c25800dcd39387a9a831ef8f436a6bebb8e72.tar.gz
symfony-security-a57c25800dcd39387a9a831ef8f436a6bebb8e72.tar.bz2
Merge branch '2.8' into 3.1
* 2.8: fixed obsolete getMock() usage fixed obsolete getMock() usage [WebProfilerBundle] Display multiple HTTP headers in WDT do not remove the Twig ExceptionController service removed obsolete condition do not try to register incomplete definitions
-rw-r--r--Core/Tests/Authentication/AuthenticationProviderManagerTest.php24
-rw-r--r--Core/Tests/Authentication/AuthenticationTrustResolverTest.php6
-rw-r--r--Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php6
-rw-r--r--Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php52
-rw-r--r--Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php16
-rw-r--r--Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php14
-rw-r--r--Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php26
-rw-r--r--Core/Tests/Authentication/Token/AbstractTokenTest.php12
-rw-r--r--Core/Tests/Authentication/Token/RememberMeTokenTest.php2
-rw-r--r--Core/Tests/Authentication/Token/Storage/TokenStorageTest.php2
-rw-r--r--Core/Tests/Authorization/AuthorizationCheckerTest.php10
-rw-r--r--Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php6
-rw-r--r--Core/Tests/Authorization/Voter/RoleVoterTest.php2
-rw-r--r--Core/Tests/Authorization/Voter/VoterTest.php2
-rw-r--r--Core/Tests/Encoder/EncoderFactoryTest.php4
-rw-r--r--Core/Tests/Encoder/UserPasswordEncoderTest.php12
-rw-r--r--Core/Tests/Role/SwitchUserRoleTest.php4
-rw-r--r--Core/Tests/User/ChainUserProviderTest.php4
-rw-r--r--Core/Tests/User/UserCheckerTest.php16
-rw-r--r--Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php12
-rw-r--r--Csrf/Tests/CsrfTokenManagerTest.php4
-rw-r--r--Guard/Tests/Firewall/GuardAuthenticationListenerTest.php22
-rw-r--r--Guard/Tests/GuardAuthenticatorHandlerTest.php8
-rw-r--r--Guard/Tests/Provider/GuardAuthenticationProviderTest.php20
-rw-r--r--Http/Tests/AccessMapTest.php6
-rw-r--r--Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php16
-rw-r--r--Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php10
-rw-r--r--Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php12
-rw-r--r--Http/Tests/EntryPoint/BasicAuthenticationEntryPointTest.php4
-rw-r--r--Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php6
-rw-r--r--Http/Tests/EntryPoint/FormAuthenticationEntryPointTest.php14
-rw-r--r--Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php32
-rw-r--r--Http/Tests/Firewall/AccessListenerTest.php54
-rw-r--r--Http/Tests/Firewall/AnonymousAuthenticationListenerTest.php22
-rw-r--r--Http/Tests/Firewall/BasicAuthenticationListenerTest.php50
-rw-r--r--Http/Tests/Firewall/ChannelListenerTest.php32
-rw-r--r--Http/Tests/Firewall/ContextListenerTest.php32
-rw-r--r--Http/Tests/Firewall/DigestAuthenticationListenerTest.php8
-rw-r--r--Http/Tests/Firewall/ExceptionListenerTest.php22
-rw-r--r--Http/Tests/Firewall/LogoutListenerTest.php10
-rw-r--r--Http/Tests/Firewall/RememberMeListenerTest.php38
-rw-r--r--Http/Tests/Firewall/RemoteUserAuthenticationListenerTest.php12
-rw-r--r--Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php14
-rw-r--r--Http/Tests/Firewall/SwitchUserListenerTest.php36
-rw-r--r--Http/Tests/Firewall/X509AuthenticationListenerTest.php16
-rw-r--r--Http/Tests/FirewallMapTest.php30
-rw-r--r--Http/Tests/FirewallTest.php42
-rw-r--r--Http/Tests/HttpUtilsTest.php24
-rw-r--r--Http/Tests/Logout/CookieClearingLogoutHandlerTest.php2
-rw-r--r--Http/Tests/Logout/DefaultLogoutSuccessHandlerTest.php4
-rw-r--r--Http/Tests/Logout/SessionLogoutHandlerTest.php6
-rw-r--r--Http/Tests/RememberMe/AbstractRememberMeServicesTest.php26
-rw-r--r--Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php32
-rw-r--r--Http/Tests/RememberMe/ResponseListenerTest.php2
-rw-r--r--Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php16
55 files changed, 458 insertions, 458 deletions
diff --git a/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
index cc8b7c0..274992e 100644
--- a/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
+++ b/Core/Tests/Authentication/AuthenticationProviderManagerTest.php
@@ -44,7 +44,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (ProviderNotFoundException $e) {
$this->assertSame($token, $e->getToken());
@@ -58,7 +58,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (AccountStatusException $e) {
$this->assertSame($token, $e->getToken());
@@ -72,7 +72,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
));
try {
- $manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->fail();
} catch (AuthenticationException $e) {
$this->assertSame($token, $e->getToken());
@@ -83,26 +83,26 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
{
$manager = new AuthenticationProviderManager(array(
$this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'),
- $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
+ $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($expected, $token);
}
public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider()
{
- $second = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
+ $second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
$second
->expects($this->never())
->method('supports')
;
$manager = new AuthenticationProviderManager(array(
- $this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
+ $this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
$second,
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($expected, $token);
}
@@ -112,20 +112,20 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
));
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('', $token->getCredentials());
$manager = new AuthenticationProviderManager(array(
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
), false);
- $token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('bar', $token->getCredentials());
}
protected function getAuthenticationProvider($supports, $token = null, $exception = null)
{
- $provider = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
+ $provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
$provider->expects($this->once())
->method('supports')
->will($this->returnValue($supports))
@@ -139,7 +139,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
} elseif (null !== $exception) {
$provider->expects($this->once())
->method('authenticate')
- ->will($this->throwException($this->getMock($exception, null, array(), '')))
+ ->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
;
}
diff --git a/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
index 3640981..e3f7f5f 100644
--- a/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
+++ b/Core/Tests/Authentication/AuthenticationTrustResolverTest.php
@@ -47,17 +47,17 @@ class AuthenticationTrustResolverTest extends \PHPUnit_Framework_TestCase
protected function getToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
protected function getAnonymousToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', ''));
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock();
}
protected function getRememberMeToken()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock();
}
protected function getResolver()
diff --git a/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
index 8f4b392..f22227b 100644
--- a/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php
@@ -20,14 +20,14 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider('foo');
$this->assertTrue($provider->supports($this->getSupportedToken('foo')));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider('foo');
- $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
/**
@@ -50,7 +50,7 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getSupportedToken($secret)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getSecret'), array(), '', false);
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getSecret'))->disableOriginalConstructor()->getMock();
$token->expects($this->any())
->method('getSecret')
->will($this->returnValue($secret))
diff --git a/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
index 3eedb8e..8edf1b0 100644
--- a/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
@@ -34,13 +34,13 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testRetrieveUserWhenUsernameIsNotFound()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->throwException(new UsernameNotFoundException()))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -52,13 +52,13 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testRetrieveUserWhenAnExceptionOccurs()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->throwException(new \RuntimeException()))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -67,19 +67,19 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->never())
->method('loadUserByUsername')
;
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$token = $this->getSupportedToken();
$token->expects($this->once())
->method('getUser')
->will($this->returnValue($user))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$reflection = new \ReflectionMethod($provider, 'retrieveUser');
$reflection->setAccessible(true);
$result = $reflection->invoke($provider, null, $token);
@@ -89,15 +89,15 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUser()
{
- $user = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once())
->method('loadUserByUsername')
->will($this->returnValue($user))
;
- $provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
+ $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
$method = new \ReflectionMethod($provider, 'retrieveUser');
$method->setAccessible(true);
@@ -109,7 +109,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationWhenCredentialsAreEmpty()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder
->expects($this->never())
->method('isPasswordValid')
@@ -128,14 +128,14 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$method->invoke(
$provider,
- $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'),
+ $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
$token
);
}
public function testCheckAuthenticationWhenCredentialsAre0()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder
->expects($this->once())
->method('isPasswordValid')
@@ -155,7 +155,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$method->invoke(
$provider,
- $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'),
+ $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
$token
);
}
@@ -165,7 +165,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationWhenCredentialsAreNotValid()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
->will($this->returnValue(false))
@@ -181,7 +181,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token);
+ $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
}
/**
@@ -189,7 +189,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
{
- $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')
->will($this->returnValue('foo'))
@@ -200,7 +200,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('getUser')
->will($this->returnValue($user));
- $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
->will($this->returnValue('newFoo'))
@@ -214,7 +214,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials()
{
- $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')
->will($this->returnValue('foo'))
@@ -225,7 +225,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('getUser')
->will($this->returnValue($user));
- $dbUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
+ $dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
$dbUser->expects($this->once())
->method('getPassword')
->will($this->returnValue('foo'))
@@ -239,7 +239,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testCheckAuthentication()
{
- $encoder = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
+ $encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
$encoder->expects($this->once())
->method('isPasswordValid')
->will($this->returnValue(true))
@@ -255,12 +255,12 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $method->invoke($provider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface'), $token);
+ $method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
}
protected function getSupportedToken()
{
- $mock = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken', array('getCredentials', 'getUser', 'getProviderKey'), array(), '', false);
+ $mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(array('getCredentials', 'getUser', 'getProviderKey'))->disableOriginalConstructor()->getMock();
$mock
->expects($this->any())
->method('getProviderKey')
@@ -272,7 +272,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null)
{
- $userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -281,14 +281,14 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
}
if (null === $userChecker) {
- $userChecker = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock();
}
if (null === $passwordEncoder) {
$passwordEncoder = new PlaintextPasswordEncoder();
}
- $encoderFactory = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface');
+ $encoderFactory = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock();
$encoderFactory
->expects($this->any())
->method('getEncoder')
diff --git a/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
index 5fd7b05..27d8566 100644
--- a/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php
@@ -21,7 +21,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
$provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken()));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')
->disableOriginalConstructor()
@@ -39,7 +39,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
{
$provider = $this->getProvider();
- $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
/**
@@ -53,7 +53,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
public function testAuthenticate()
{
- $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')
@@ -75,9 +75,9 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
*/
public function testAuthenticateWhenUserCheckerThrowsException()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPostAuth')
->will($this->throwException(new LockedException()))
@@ -90,7 +90,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
protected function getSupportedToken($user = false, $credentials = false)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken', array('getUser', 'getCredentials', 'getProviderKey'), array(), '', false);
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')->setMethods(array('getUser', 'getCredentials', 'getProviderKey'))->disableOriginalConstructor()->getMock();
if (false !== $user) {
$token->expects($this->once())
->method('getUser')
@@ -117,7 +117,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
protected function getProvider($user = null, $userChecker = null)
{
- $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
if (null !== $user) {
$userProvider->expects($this->once())
->method('loadUserByUsername')
@@ -126,7 +126,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
}
if (null === $userChecker) {
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
}
return new PreAuthenticatedAuthenticationProvider($userProvider, $userChecker, 'key');
diff --git a/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
index 735d195..2099d98 100644
--- a/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
@@ -22,14 +22,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken()));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->assertNull($provider->authenticate($token));
}
@@ -49,7 +49,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testAuthenticateWhenPreChecksFails()
{
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPreAuth')
->will($this->throwException(new DisabledException()));
@@ -61,7 +61,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testAuthenticate()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->exactly(2))
->method('getRoles')
->will($this->returnValue(array('ROLE_FOO')));
@@ -80,14 +80,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getSupportedToken($user = null, $secret = 'test')
{
if (null === $user) {
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user
->expects($this->any())
->method('getRoles')
->will($this->returnValue(array()));
}
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $secret));
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('getProviderKey'))->setConstructorArgs(array($user, 'foo', $secret))->getMock();
$token
->expects($this->once())
->method('getProviderKey')
@@ -99,7 +99,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getProvider($userChecker = null, $key = 'test')
{
if (null === $userChecker) {
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
}
return new RememberMeAuthenticationProvider($userChecker, $key, 'foo');
diff --git a/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
index 0503054..0a78ee8 100644
--- a/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php
@@ -25,14 +25,14 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider();
$this->assertTrue($provider->supports($this->getSupportedToken()));
- $this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();
- $this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
+ $this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}
/**
@@ -82,7 +82,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testAuthenticateWhenPreChecksFails()
{
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPreAuth')
->will($this->throwException(new CredentialsExpiredException()))
@@ -91,7 +91,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->authenticate($this->getSupportedToken());
@@ -102,7 +102,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testAuthenticateWhenPostChecksFails()
{
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once())
->method('checkPostAuth')
->will($this->throwException(new AccountExpiredException()))
@@ -111,7 +111,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider($userChecker);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->authenticate($this->getSupportedToken());
@@ -126,7 +126,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider();
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -145,7 +145,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$provider = $this->getProvider(false, false);
$provider->expects($this->once())
->method('retrieveUser')
- ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\User\UserInterface')))
+ ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()))
;
$provider->expects($this->once())
->method('checkAuthentication')
@@ -157,7 +157,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testAuthenticate()
{
- $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')
->will($this->returnValue(array('ROLE_FOO')))
@@ -191,7 +191,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testAuthenticateWithPreservingRoleSwitchUserRole()
{
- $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')
->will($this->returnValue(array('ROLE_FOO')))
@@ -209,7 +209,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('foo'))
;
- $switchUserRole = new SwitchUserRole('foo', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$token->expects($this->once())
->method('getRoles')
->will($this->returnValue(array($switchUserRole)))
@@ -227,7 +227,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getSupportedToken()
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', array('getCredentials', 'getProviderKey', 'getRoles'), array(), '', false);
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken')->setMethods(array('getCredentials', 'getProviderKey', 'getRoles'))->disableOriginalConstructor()->getMock();
$mock
->expects($this->any())
->method('getProviderKey')
@@ -242,7 +242,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function getProvider($userChecker = false, $hide = true)
{
if (false === $userChecker) {
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
}
return $this->getMockForAbstractClass('Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider', array($userChecker, 'key', $hide));
diff --git a/Core/Tests/Authentication/Token/AbstractTokenTest.php b/Core/Tests/Authentication/Token/AbstractTokenTest.php
index 1a786d7..896ea37 100644
--- a/Core/Tests/Authentication/Token/AbstractTokenTest.php
+++ b/Core/Tests/Authentication/Token/AbstractTokenTest.php
@@ -68,7 +68,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$token->setUser(new TestUser('fabien'));
$this->assertEquals('fabien', $token->getUsername());
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->expects($this->once())->method('getUsername')->will($this->returnValue('fabien'));
$token->setUser($user);
$this->assertEquals('fabien', $token->getUsername());
@@ -78,7 +78,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
{
$token = $this->getToken(array('ROLE_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('eraseCredentials');
$token->setUser($user);
@@ -168,8 +168,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
public function getUsers()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
return array(
array($advancedUser),
@@ -197,8 +197,8 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
public function getUserChanges()
{
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
- $advancedUser = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
+ $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
return array(
array(
diff --git a/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/Core/Tests/Authentication/Token/RememberMeTokenTest.php
index b83de4a..882f222 100644
--- a/Core/Tests/Authentication/Token/RememberMeTokenTest.php
+++ b/Core/Tests/Authentication/Token/RememberMeTokenTest.php
@@ -54,7 +54,7 @@ class RememberMeTokenTest extends \PHPUnit_Framework_TestCase
protected function getUser($roles = array('ROLE_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')
diff --git a/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php b/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
index d06e3f0..a3bcc96 100644
--- a/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
+++ b/Core/Tests/Authentication/Token/Storage/TokenStorageTest.php
@@ -19,7 +19,7 @@ class TokenStorageTest extends \PHPUnit_Framework_TestCase
{
$tokenStorage = new TokenStorage();
$this->assertNull($tokenStorage->getToken());
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage->setToken($token);
$this->assertSame($token, $tokenStorage->getToken());
}
diff --git a/Core/Tests/Authorization/AuthorizationCheckerTest.php b/Core/Tests/Authorization/AuthorizationCheckerTest.php
index aafc12f..eed361c 100644
--- a/Core/Tests/Authorization/AuthorizationCheckerTest.php
+++ b/Core/Tests/Authorization/AuthorizationCheckerTest.php
@@ -23,8 +23,8 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $this->accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface');
+ $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
+ $this->accessDecisionManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface')->getMock();
$this->tokenStorage = new TokenStorage();
$this->authorizationChecker = new AuthorizationChecker(
@@ -36,10 +36,10 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
public function testVoteAuthenticatesTokenIfNecessary()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->tokenStorage->setToken($token);
- $newToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $newToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->authenticationManager
->expects($this->once())
@@ -78,7 +78,7 @@ class AuthorizationCheckerTest extends \PHPUnit_Framework_TestCase
*/
public function testIsGranted($decide)
{
- $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('isAuthenticated')
diff --git a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
index 60e2a19..d685f0f 100644
--- a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
+++ b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php
@@ -62,11 +62,11 @@ class AuthenticatedVoterTest extends \PHPUnit_Framework_TestCase
protected function getToken($authenticated)
{
if ('fully' === $authenticated) {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
} elseif ('remembered' === $authenticated) {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false);
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock();
} else {
- return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', ''));
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock();
}
}
}
diff --git a/Core/Tests/Authorization/Voter/RoleVoterTest.php b/Core/Tests/Authorization/Voter/RoleVoterTest.php
index 45535ca..5918fd8 100644
--- a/Core/Tests/Authorization/Voter/RoleVoterTest.php
+++ b/Core/Tests/Authorization/Voter/RoleVoterTest.php
@@ -50,7 +50,7 @@ class RoleVoterTest extends \PHPUnit_Framework_TestCase
foreach ($roles as $i => $role) {
$roles[$i] = new Role($role);
}
- $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('getRoles')
->will($this->returnValue($roles));
diff --git a/Core/Tests/Authorization/Voter/VoterTest.php b/Core/Tests/Authorization/Voter/VoterTest.php
index 4bac44d..cbd2755 100644
--- a/Core/Tests/Authorization/Voter/VoterTest.php
+++ b/Core/Tests/Authorization/Voter/VoterTest.php
@@ -21,7 +21,7 @@ class VoterTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
}
public function getTests()
diff --git a/Core/Tests/Encoder/EncoderFactoryTest.php b/Core/Tests/Encoder/EncoderFactoryTest.php
index 21aaae4..191a4d8 100644
--- a/Core/Tests/Encoder/EncoderFactoryTest.php
+++ b/Core/Tests/Encoder/EncoderFactoryTest.php
@@ -26,7 +26,7 @@ class EncoderFactoryTest extends \PHPUnit_Framework_TestCase
'arguments' => array('sha512', true, 5),
)));
- $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$expectedEncoder = new MessageDigestPasswordEncoder('sha512', true, 5);
$this->assertEquals($expectedEncoder->encodePassword('foo', 'moo'), $encoder->encodePassword('foo', 'moo'));
@@ -38,7 +38,7 @@ class EncoderFactoryTest extends \PHPUnit_Framework_TestCase
'Symfony\Component\Security\Core\User\UserInterface' => new MessageDigestPasswordEncoder('sha1'),
));
- $encoder = $factory->getEncoder($this->getMock('Symfony\Component\Security\Core\User\UserInterface'));
+ $encoder = $factory->getEncoder($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
$expectedEncoder = new MessageDigestPasswordEncoder('sha1');
$this->assertEquals($expectedEncoder->encodePassword('foo', ''), $encoder->encodePassword('foo', ''));
diff --git a/Core/Tests/Encoder/UserPasswordEncoderTest.php b/Core/Tests/Encoder/UserPasswordEncoderTest.php
index 590652d..e8adb9b 100644
--- a/Core/Tests/Encoder/UserPasswordEncoderTest.php
+++ b/Core/Tests/Encoder/UserPasswordEncoderTest.php
@@ -17,18 +17,18 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
{
public function testEncodePassword()
{
- $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
->will($this->returnValue('userSalt'));
- $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('encodePassword')
->with($this->equalTo('plainPassword'), $this->equalTo('userSalt'))
->will($this->returnValue('encodedPassword'));
- $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
@@ -42,7 +42,7 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
public function testIsPasswordValid()
{
- $userMock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $userMock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$userMock->expects($this->any())
->method('getSalt')
->will($this->returnValue('userSalt'));
@@ -50,13 +50,13 @@ class UserPasswordEncoderTest extends \PHPUnit_Framework_TestCase
->method('getPassword')
->will($this->returnValue('encodedPassword'));
- $mockEncoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ $mockEncoder = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
$mockEncoder->expects($this->any())
->method('isPasswordValid')
->with($this->equalTo('encodedPassword'), $this->equalTo('plainPassword'), $this->equalTo('userSalt'))
->will($this->returnValue(true));
- $mockEncoderFactory = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mockEncoderFactory = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mockEncoderFactory->expects($this->any())
->method('getEncoder')
->with($this->equalTo($userMock))
diff --git a/Core/Tests/Role/SwitchUserRoleTest.php b/Core/Tests/Role/SwitchUserRoleTest.php
index f0ce468..fff5ff2 100644
--- a/Core/Tests/Role/SwitchUserRoleTest.php
+++ b/Core/Tests/Role/SwitchUserRoleTest.php
@@ -17,14 +17,14 @@ class SwitchUserRoleTest extends \PHPUnit_Framework_TestCase
{
public function testGetSource()
{
- $role = new SwitchUserRole('FOO', $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertSame($token, $role->getSource());
}
public function testGetRole()
{
- $role = new SwitchUserRole('FOO', $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
+ $role = new SwitchUserRole('FOO', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
$this->assertEquals('FOO', $role->getRole());
}
diff --git a/Core/Tests/User/ChainUserProviderTest.php b/Core/Tests/User/ChainUserProviderTest.php
index ab01f47..dae58ae 100644
--- a/Core/Tests/User/ChainUserProviderTest.php
+++ b/Core/Tests/User/ChainUserProviderTest.php
@@ -173,11 +173,11 @@ class ChainUserProviderTest extends \PHPUnit_Framework_TestCase
protected function getAccount()
{
- return $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
}
protected function getProvider()
{
- return $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
}
}
diff --git a/Core/Tests/User/UserCheckerTest.php b/Core/Tests/User/UserCheckerTest.php
index ac21781..4b6e527 100644
--- a/Core/Tests/User/UserCheckerTest.php
+++ b/Core/Tests/User/UserCheckerTest.php
@@ -19,14 +19,14 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $this->assertNull($checker->checkPostAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
+ $this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()));
}
public function testCheckPostAuthPass()
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true));
$this->assertNull($checker->checkPostAuth($account));
@@ -39,7 +39,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false));
$checker->checkPostAuth($account);
@@ -49,14 +49,14 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $this->assertNull($checker->checkPreAuth($this->getMock('Symfony\Component\Security\Core\User\UserInterface')));
+ $this->assertNull($checker->checkPreAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()));
}
public function testCheckPreAuthPass()
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
$account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true));
@@ -71,7 +71,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false));
$checker->checkPreAuth($account);
@@ -84,7 +84,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
@@ -98,7 +98,7 @@ class UserCheckerTest extends \PHPUnit_Framework_TestCase
{
$checker = new UserChecker();
- $account = $this->getMock('Symfony\Component\Security\Core\User\AdvancedUserInterface');
+ $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock();
$account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true));
$account->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
$account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false));
diff --git a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
index 047c929..7ebe65c 100644
--- a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
+++ b/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php
@@ -95,7 +95,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
*/
public function testUserIsNotValid()
{
- $user = $this->getMock('Foo\Bar\User');
+ $user = $this->getMockBuilder('Foo\Bar\User')->getMock();
$this->tokenStorage = $this->createTokenStorage($user);
$this->validator = $this->createValidator();
@@ -106,7 +106,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createUser()
{
- $mock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$mock
->expects($this->any())
@@ -125,12 +125,12 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createPasswordEncoder($isPasswordValid = true)
{
- return $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface')->getMock();
}
protected function createEncoderFactory($encoder = null)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface')->getMock();
$mock
->expects($this->any())
@@ -145,7 +145,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
{
$token = $this->createAuthenticationToken($user);
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$mock
->expects($this->any())
->method('getToken')
@@ -157,7 +157,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
protected function createAuthenticationToken($user = null)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$mock
->expects($this->any())
->method('getUser')
diff --git a/Csrf/Tests/CsrfTokenManagerTest.php b/Csrf/Tests/CsrfTokenManagerTest.php
index 3112038..16baec1 100644
--- a/Csrf/Tests/CsrfTokenManagerTest.php
+++ b/Csrf/Tests/CsrfTokenManagerTest.php
@@ -36,8 +36,8 @@ class CsrfTokenManagerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->generator = $this->getMock('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface');
- $this->storage = $this->getMock('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface');
+ $this->generator = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface')->getMock();
+ $this->storage = $this->getMockBuilder('Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface')->getMock();
$this->manager = new CsrfTokenManager($this->generator, $this->storage);
}
diff --git a/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
index 3224fee..dee7ad1 100644
--- a/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
+++ b/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php
@@ -31,8 +31,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleSuccess()
{
- $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$providerKey = 'my_firewall';
$credentials = array('username' => 'weaverryan', 'password' => 'all_your_base');
@@ -81,8 +81,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleSuccessStopsAfterResponseIsSet()
{
- $authenticator1 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticator2 = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $authenticator1 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticator2 = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
// mock the first authenticator to fail, and set a Response
$authenticator1
@@ -111,8 +111,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleSuccessWithRememberMe()
{
- $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticateToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticateToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$providerKey = 'my_firewall_with_rememberme';
$authenticator
@@ -154,7 +154,7 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testHandleCatchesAuthenticationException()
{
- $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
$providerKey = 'my_firewall2';
$authException = new AuthenticationException('Get outta here crazy user with a bad password!');
@@ -186,8 +186,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
public function testReturnNullToSkipAuth()
{
- $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
$providerKey = 'my_firewall3';
$authenticatorA
@@ -240,8 +240,8 @@ class GuardAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
->method('getRequest')
->will($this->returnValue($this->request));
- $this->logger = $this->getMock('Psr\Log\LoggerInterface');
- $this->rememberMeServices = $this->getMock('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface');
+ $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
+ $this->rememberMeServices = $this->getMockBuilder('Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface')->getMock();
}
protected function tearDown()
diff --git a/Guard/Tests/GuardAuthenticatorHandlerTest.php b/Guard/Tests/GuardAuthenticatorHandlerTest.php
index 6f36702..58a3e17 100644
--- a/Guard/Tests/GuardAuthenticatorHandlerTest.php
+++ b/Guard/Tests/GuardAuthenticatorHandlerTest.php
@@ -123,11 +123,11 @@ class GuardAuthenticatorHandlerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
- $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
- $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
+ $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->request = new Request(array(), array(), array(), array(), array(), array());
- $this->guardAuthenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $this->guardAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
}
protected function tearDown()
diff --git a/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
index bfcf24b..e7e323a 100644
--- a/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
+++ b/Guard/Tests/Provider/GuardAuthenticationProviderTest.php
@@ -27,9 +27,9 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
{
$providerKey = 'my_cool_firewall';
- $authenticatorA = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticatorB = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
- $authenticatorC = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
+ $authenticatorC = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
$authenticators = array($authenticatorA, $authenticatorB, $authenticatorC);
// called 2 times - for authenticator A and B (stops on B because of match)
@@ -52,7 +52,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
$authenticatorC->expects($this->never())
->method('getUser');
- $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$authenticatorB->expects($this->once())
->method('getUser')
->with($enteredCredentials, $this->userProvider)
@@ -63,7 +63,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->with($enteredCredentials, $mockedUser)
// authentication works!
->will($this->returnValue(true));
- $authedToken = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$authenticatorB->expects($this->once())
->method('createAuthenticatedToken')
->with($mockedUser, $providerKey)
@@ -89,7 +89,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
{
$providerKey = 'my_uncool_firewall';
- $authenticator = $this->getMock('Symfony\Component\Security\Guard\GuardAuthenticatorInterface');
+ $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock();
// make sure the authenticator is used
$this->preAuthenticationToken->expects($this->any())
@@ -101,7 +101,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
->method('getCredentials')
->will($this->returnValue('non-null-value'));
- $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$authenticator->expects($this->once())
->method('getUser')
->will($this->returnValue($mockedUser));
@@ -124,7 +124,7 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
// create a token and mark it as NOT authenticated anymore
// this mimics what would happen if a user "changed" between request
- $mockedUser = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$token = new PostAuthenticationGuardToken($mockedUser, $providerKey, array('ROLE_USER'));
$token->setAuthenticated(false);
@@ -134,8 +134,8 @@ class GuardAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
- $this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $this->userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
+ $this->userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$this->preAuthenticationToken = $this->getMockBuilder('Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken')
->disableOriginalConstructor()
->getMock();
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 c97ee69..cb5fb51 100644
--- a/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
+++ b/Http/Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php
@@ -27,14 +27,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()
@@ -181,8 +181,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 5372993..8b937c5 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()
@@ -101,7 +101,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 4082986..e9c7f10 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', 'TheSecret');
$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 d99b562..ba740c4 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, 'TheSecret', 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('TheSecret', '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, 'TheSecret', 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, 'TheSecret', $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 0213330..3af6201 100644
--- a/Http/Tests/Firewall/ContextListenerTest.php
+++ b/Http/Tests/Firewall/ContextListenerTest.php
@@ -33,7 +33,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(),
''
);
@@ -46,7 +46,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'
);
@@ -102,7 +102,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()
@@ -121,7 +121,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()
@@ -138,12 +138,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')
@@ -177,8 +177,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();
@@ -190,7 +190,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')
@@ -201,15 +201,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));
@@ -230,7 +230,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')
@@ -238,7 +238,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');
@@ -261,7 +261,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/DigestAuthenticationListenerTest.php b/Http/Tests/Firewall/DigestAuthenticationListenerTest.php
index 80b2dc4..2a29db7 100644
--- a/Http/Tests/Firewall/DigestAuthenticationListenerTest.php
+++ b/Http/Tests/Firewall/DigestAuthenticationListenerTest.php
@@ -34,12 +34,12 @@ class DigestAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$entryPoint = new DigestAuthenticationEntryPoint($realm, $secret);
- $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
+ $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$user->method('getPassword')->willReturn($password);
$providerKey = 'TheProviderKey';
- $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('getToken')
@@ -51,12 +51,12 @@ class DigestAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo(new UsernamePasswordToken($user, $password, $providerKey)))
;
- $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
+ $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
$userProvider->method('loadUserByUsername')->willReturn($user);
$listener = new DigestAuthenticationListener($tokenStorage, $userProvider, $providerKey, $entryPoint);
- $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/ExceptionListenerTest.php b/Http/Tests/Firewall/ExceptionListenerTest.php
index db0a242..ffa7cd8 100644
--- a/Http/Tests/Firewall/ExceptionListenerTest.php
+++ b/Http/Tests/Firewall/ExceptionListenerTest.php
@@ -98,12 +98,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');
@@ -120,7 +120,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);
@@ -137,8 +137,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);
@@ -160,7 +160,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;
@@ -168,7 +168,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;
@@ -177,7 +177,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);
@@ -186,9 +186,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 367c810..8f6db59 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 adf91b1..90ce1e6 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\Http\Authentication\SimplePreAuthenticatorInterface');
+ $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\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\Http\Authentication\SimplePreAuthenticatorInterface');
+ $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\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 7495398..84d11e7 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 30cf4a2..6628b5b 100644
--- a/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
+++ b/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
@@ -60,7 +60,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')
@@ -79,7 +79,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')
@@ -104,7 +104,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
@@ -135,7 +135,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')
@@ -150,7 +150,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')
@@ -169,7 +169,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')
@@ -192,9 +192,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')
@@ -218,9 +218,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')
@@ -241,9 +241,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')
@@ -271,20 +271,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')
@@ -326,7 +326,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 ee8a99e..ce1048e 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')