summaryrefslogtreecommitdiffstats
path: root/Core/Tests/Authentication/Provider
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-12-19 16:38:44 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2016-12-19 16:38:44 +0100
commitb61218eac019add58b6eaf5bd0bdf331fb375ffb (patch)
tree81d5e0ad1bc52ea5cb4bcc570556e886c29fdc8c /Core/Tests/Authentication/Provider
parent8a7bf02f6038110dbf43a6c7dbf247acccac9817 (diff)
parent0582ad240b9aa4b86945b3fdee0f84b20eb0856f (diff)
downloadsymfony-security-b61218eac019add58b6eaf5bd0bdf331fb375ffb.zip
symfony-security-b61218eac019add58b6eaf5bd0bdf331fb375ffb.tar.gz
symfony-security-b61218eac019add58b6eaf5bd0bdf331fb375ffb.tar.bz2
Merge branch '2.7' into 2.8
* 2.7: fixed obsolete getMock() usage [WebProfilerBundle] Display multiple HTTP headers in WDT
Diffstat (limited to 'Core/Tests/Authentication/Provider')
-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/UserAuthenticationProviderTest.php26
3 files changed, 47 insertions, 47 deletions
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/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));