[Tests] Change to willThrowException

This commit is contained in:
George Mponos 2018-12-22 21:54:00 +02:00 committed by Fabien Potencier
parent 2437d70c2c
commit 0695834657
25 changed files with 52 additions and 52 deletions

View File

@ -103,7 +103,7 @@ class TranslationDebugCommandTest extends TestCase
$kernel->expects($this->once()) $kernel->expects($this->once())
->method('getBundle') ->method('getBundle')
->with($this->equalTo('dir')) ->with($this->equalTo('dir'))
->will($this->throwException(new \InvalidArgumentException())); ->willThrowException(new \InvalidArgumentException());
$tester = $this->createCommandTester(array(), array(), $kernel); $tester = $this->createCommandTester(array(), array(), $kernel);
$tester->execute(array('locale' => 'en', 'bundle' => 'dir')); $tester->execute(array('locale' => 'en', 'bundle' => 'dir'));

View File

@ -60,7 +60,7 @@ class TemplateLocatorTest extends TestCase
$fileLocator $fileLocator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->will($this->throwException(new \InvalidArgumentException($errorMessage))) ->willThrowException(new \InvalidArgumentException($errorMessage))
; ;
$locator = new TemplateLocator($fileLocator); $locator = new TemplateLocator($fileLocator);

View File

@ -68,7 +68,7 @@ class FilesystemLoaderTest extends TestCase
$locator $locator
->expects($this->once()) ->expects($this->once())
->method('locate') ->method('locate')
->will($this->throwException(new \InvalidArgumentException('Unable to find template "NonExistent".'))) ->willThrowException(new \InvalidArgumentException('Unable to find template "NonExistent".'))
; ;
$loader = new FilesystemLoader($locator, $parser); $loader = new FilesystemLoader($locator, $parser);

View File

@ -252,7 +252,7 @@ class WebDebugToolbarListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('generate') ->method('generate')
->with('_profiler', array('token' => 'xxxxxxxx')) ->with('_profiler', array('token' => 'xxxxxxxx'))
->will($this->throwException(new \Exception('foo'))) ->willThrowException(new \Exception('foo'))
; ;
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
@ -273,7 +273,7 @@ class WebDebugToolbarListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('generate') ->method('generate')
->with('_profiler', array('token' => 'xxxxxxxx')) ->with('_profiler', array('token' => 'xxxxxxxx'))
->will($this->throwException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))) ->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))
; ;
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response); $event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);

View File

@ -919,7 +919,7 @@ class ApplicationTest extends TestCase
$application->setAutoExit(false); $application->setAutoExit(false);
$application->expects($this->once()) $application->expects($this->once())
->method('doRun') ->method('doRun')
->will($this->throwException($exception)); ->willThrowException($exception);
$exitCode = $application->run(new ArrayInput(array()), new NullOutput()); $exitCode = $application->run(new ArrayInput(array()), new NullOutput());
@ -958,7 +958,7 @@ class ApplicationTest extends TestCase
$application->setAutoExit(false); $application->setAutoExit(false);
$application->expects($this->once()) $application->expects($this->once())
->method('doRun') ->method('doRun')
->will($this->throwException($exception)); ->willThrowException($exception);
$exitCode = $application->run(new ArrayInput(array()), new NullOutput()); $exitCode = $application->run(new ArrayInput(array()), new NullOutput());

View File

@ -629,7 +629,7 @@ class SimpleFormTest extends AbstractFormTest
$transformer = $this->getDataTransformer(); $transformer = $this->getDataTransformer();
$transformer->expects($this->once()) $transformer->expects($this->once())
->method('reverseTransform') ->method('reverseTransform')
->will($this->throwException(new TransformationFailedException())); ->willThrowException(new TransformationFailedException());
$form = $this->getBuilder() $form = $this->getBuilder()
->addViewTransformer($transformer) ->addViewTransformer($transformer)
@ -645,7 +645,7 @@ class SimpleFormTest extends AbstractFormTest
$transformer = $this->getDataTransformer(); $transformer = $this->getDataTransformer();
$transformer->expects($this->once()) $transformer->expects($this->once())
->method('reverseTransform') ->method('reverseTransform')
->will($this->throwException(new TransformationFailedException())); ->willThrowException(new TransformationFailedException());
$form = $this->getBuilder() $form = $this->getBuilder()
->addModelTransformer($transformer) ->addModelTransformer($transformer)

View File

@ -47,7 +47,7 @@ class TranslatorListenerTest extends TestCase
$this->translator $this->translator
->expects($this->at(0)) ->expects($this->at(0))
->method('setLocale') ->method('setLocale')
->will($this->throwException(new \InvalidArgumentException())); ->willThrowException(new \InvalidArgumentException());
$this->translator $this->translator
->expects($this->at(1)) ->expects($this->at(1))
->method('setLocale') ->method('setLocale')
@ -84,7 +84,7 @@ class TranslatorListenerTest extends TestCase
$this->translator $this->translator
->expects($this->at(0)) ->expects($this->at(0))
->method('setLocale') ->method('setLocale')
->will($this->throwException(new \InvalidArgumentException())); ->willThrowException(new \InvalidArgumentException());
$this->translator $this->translator
->expects($this->at(1)) ->expects($this->at(1))
->method('setLocale') ->method('setLocale')

View File

@ -80,7 +80,7 @@ class HIncludeFragmentRendererTest extends TestCase
$engine->expects($this->once()) $engine->expects($this->once())
->method('exists') ->method('exists')
->with('default') ->with('default')
->will($this->throwException(new \InvalidArgumentException())); ->willThrowException(new \InvalidArgumentException());
// only default // only default
$strategy = new HIncludeFragmentRenderer($engine); $strategy = new HIncludeFragmentRenderer($engine);
@ -93,7 +93,7 @@ class HIncludeFragmentRendererTest extends TestCase
$engine->expects($this->once()) $engine->expects($this->once())
->method('exists') ->method('exists')
->with('loading...') ->with('loading...')
->will($this->throwException(new \RuntimeException())); ->willThrowException(new \RuntimeException());
// only default // only default
$strategy = new HIncludeFragmentRenderer($engine); $strategy = new HIncludeFragmentRenderer($engine);

View File

@ -148,7 +148,7 @@ class BundleEntryReaderTest extends TestCase
$this->readerImpl->expects($this->at(0)) $this->readerImpl->expects($this->at(0))
->method('read') ->method('read')
->with(self::RES_DIR, 'en_GB') ->with(self::RES_DIR, 'en_GB')
->will($this->throwException(new ResourceBundleNotFoundException())); ->willThrowException(new ResourceBundleNotFoundException());
$this->readerImpl->expects($this->at(1)) $this->readerImpl->expects($this->at(1))
->method('read') ->method('read')
@ -166,7 +166,7 @@ class BundleEntryReaderTest extends TestCase
$this->readerImpl->expects($this->once()) $this->readerImpl->expects($this->once())
->method('read') ->method('read')
->with(self::RES_DIR, 'en_GB') ->with(self::RES_DIR, 'en_GB')
->will($this->throwException(new ResourceBundleNotFoundException())); ->willThrowException(new ResourceBundleNotFoundException());
$this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false); $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false);
} }

View File

@ -188,7 +188,7 @@ class AuthenticationProviderManagerTest extends TestCase
} elseif (null !== $exception) { } elseif (null !== $exception) {
$provider->expects($this->once()) $provider->expects($this->once())
->method('authenticate') ->method('authenticate')
->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock())) ->willThrowException($this->getMockBuilder($exception)->setMethods(null)->getMock())
; ;
} }

View File

@ -38,7 +38,7 @@ class DaoAuthenticationProviderTest extends TestCase
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once()) $userProvider->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->will($this->throwException(new UsernameNotFoundException())) ->willThrowException(new UsernameNotFoundException())
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
@ -56,7 +56,7 @@ class DaoAuthenticationProviderTest extends TestCase
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock(); $userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
$userProvider->expects($this->once()) $userProvider->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->will($this->throwException(new \RuntimeException())) ->willThrowException(new \RuntimeException())
; ;
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock()); $provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());

View File

@ -73,7 +73,7 @@ class LdapBindAuthenticationProviderTest extends TestCase
$ldap $ldap
->expects($this->once()) ->expects($this->once())
->method('bind') ->method('bind')
->will($this->throwException(new ConnectionException())) ->willThrowException(new ConnectionException())
; ;
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock(); $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();

View File

@ -85,7 +85,7 @@ class PreAuthenticatedAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPostAuth') ->method('checkPostAuth')
->will($this->throwException(new LockedException())) ->willThrowException(new LockedException())
; ;
$provider = $this->getProvider($user, $userChecker); $provider = $this->getProvider($user, $userChecker);

View File

@ -57,7 +57,7 @@ class RememberMeAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPreAuth') ->method('checkPreAuth')
->will($this->throwException(new DisabledException())); ->willThrowException(new DisabledException());
$provider = $this->getProvider($userChecker); $provider = $this->getProvider($userChecker);

View File

@ -34,7 +34,7 @@ class SimpleAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPreAuth') ->method('checkPreAuth')
->will($this->throwException(new DisabledException())); ->willThrowException(new DisabledException());
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$authenticator->expects($this->once()) $authenticator->expects($this->once())
@ -61,7 +61,7 @@ class SimpleAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPostAuth') ->method('checkPostAuth')
->will($this->throwException(new LockedException())); ->willThrowException(new LockedException());
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
$authenticator->expects($this->once()) $authenticator->expects($this->once())

View File

@ -48,7 +48,7 @@ class UserAuthenticationProviderTest extends TestCase
$provider = $this->getProvider(false, false); $provider = $this->getProvider(false, false);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->will($this->throwException(new UsernameNotFoundException())) ->willThrowException(new UsernameNotFoundException())
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());
@ -62,7 +62,7 @@ class UserAuthenticationProviderTest extends TestCase
$provider = $this->getProvider(false, true); $provider = $this->getProvider(false, true);
$provider->expects($this->once()) $provider->expects($this->once())
->method('retrieveUser') ->method('retrieveUser')
->will($this->throwException(new UsernameNotFoundException())) ->willThrowException(new UsernameNotFoundException())
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());
@ -90,7 +90,7 @@ class UserAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPreAuth') ->method('checkPreAuth')
->will($this->throwException(new CredentialsExpiredException())) ->willThrowException(new CredentialsExpiredException())
; ;
$provider = $this->getProvider($userChecker); $provider = $this->getProvider($userChecker);
@ -110,7 +110,7 @@ class UserAuthenticationProviderTest extends TestCase
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$userChecker->expects($this->once()) $userChecker->expects($this->once())
->method('checkPostAuth') ->method('checkPostAuth')
->will($this->throwException(new AccountExpiredException())) ->willThrowException(new AccountExpiredException())
; ;
$provider = $this->getProvider($userChecker); $provider = $this->getProvider($userChecker);
@ -135,7 +135,7 @@ class UserAuthenticationProviderTest extends TestCase
; ;
$provider->expects($this->once()) $provider->expects($this->once())
->method('checkAuthentication') ->method('checkAuthentication')
->will($this->throwException(new BadCredentialsException())) ->willThrowException(new BadCredentialsException())
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());
@ -154,7 +154,7 @@ class UserAuthenticationProviderTest extends TestCase
; ;
$provider->expects($this->once()) $provider->expects($this->once())
->method('checkAuthentication') ->method('checkAuthentication')
->will($this->throwException(new BadCredentialsException('Foo'))) ->willThrowException(new BadCredentialsException('Foo'))
; ;
$provider->authenticate($this->getSupportedToken()); $provider->authenticate($this->getSupportedToken());

View File

@ -25,7 +25,7 @@ class ChainUserProviderTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->will($this->throwException(new UsernameNotFoundException('not found'))) ->willThrowException(new UsernameNotFoundException('not found'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();
@ -50,7 +50,7 @@ class ChainUserProviderTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->will($this->throwException(new UsernameNotFoundException('not found'))) ->willThrowException(new UsernameNotFoundException('not found'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();
@ -58,7 +58,7 @@ class ChainUserProviderTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->will($this->throwException(new UsernameNotFoundException('not found'))) ->willThrowException(new UsernameNotFoundException('not found'))
; ;
$provider = new ChainUserProvider(array($provider1, $provider2)); $provider = new ChainUserProvider(array($provider1, $provider2));
@ -71,7 +71,7 @@ class ChainUserProviderTest extends TestCase
$provider1 $provider1
->expects($this->once()) ->expects($this->once())
->method('refreshUser') ->method('refreshUser')
->will($this->throwException(new UnsupportedUserException('unsupported'))) ->willThrowException(new UnsupportedUserException('unsupported'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();
@ -91,7 +91,7 @@ class ChainUserProviderTest extends TestCase
$provider1 $provider1
->expects($this->once()) ->expects($this->once())
->method('refreshUser') ->method('refreshUser')
->will($this->throwException(new UsernameNotFoundException('not found'))) ->willThrowException(new UsernameNotFoundException('not found'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();
@ -114,14 +114,14 @@ class ChainUserProviderTest extends TestCase
$provider1 $provider1
->expects($this->once()) ->expects($this->once())
->method('refreshUser') ->method('refreshUser')
->will($this->throwException(new UnsupportedUserException('unsupported'))) ->willThrowException(new UnsupportedUserException('unsupported'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();
$provider2 $provider2
->expects($this->once()) ->expects($this->once())
->method('refreshUser') ->method('refreshUser')
->will($this->throwException(new UnsupportedUserException('unsupported'))) ->willThrowException(new UnsupportedUserException('unsupported'))
; ;
$provider = new ChainUserProvider(array($provider1, $provider2)); $provider = new ChainUserProvider(array($provider1, $provider2));
@ -178,7 +178,7 @@ class ChainUserProviderTest extends TestCase
$provider1 $provider1
->expects($this->once()) ->expects($this->once())
->method('refreshUser') ->method('refreshUser')
->will($this->throwException(new UnsupportedUserException('unsupported'))) ->willThrowException(new UnsupportedUserException('unsupported'))
; ;
$provider2 = $this->getProvider(); $provider2 = $this->getProvider();

View File

@ -33,7 +33,7 @@ class LdapUserProviderTest extends TestCase
$ldap $ldap
->expects($this->once()) ->expects($this->once())
->method('bind') ->method('bind')
->will($this->throwException(new ConnectionException())) ->willThrowException(new ConnectionException())
; ;
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com'); $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');

View File

@ -185,7 +185,7 @@ class GuardAuthenticationListenerTest extends TestCase
$authenticator $authenticator
->expects($this->once()) ->expects($this->once())
->method('getCredentials') ->method('getCredentials')
->will($this->throwException($authException)); ->willThrowException($authException);
// this is not called // this is not called
$this->authenticationManager $this->authenticationManager

View File

@ -90,7 +90,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
@ -138,7 +138,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
@ -228,7 +228,7 @@ class AbstractPreAuthenticatedListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken')) ->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(

View File

@ -90,7 +90,7 @@ class RememberMeListenerTest extends TestCase
$manager $manager
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$event = $this->getGetResponseEvent(); $event = $this->getGetResponseEvent();
@ -132,7 +132,7 @@ class RememberMeListenerTest extends TestCase
$manager $manager
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$event = $this->getGetResponseEvent(); $event = $this->getGetResponseEvent();
@ -159,7 +159,7 @@ class RememberMeListenerTest extends TestCase
$service $service
->expects($this->once()) ->expects($this->once())
->method('autoLogin') ->method('autoLogin')
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$service $service

View File

@ -72,7 +72,7 @@ class SimplePreAuthenticationListenerTest extends TestCase
->expects($this->once()) ->expects($this->once())
->method('authenticate') ->method('authenticate')
->with($this->equalTo($this->token)) ->with($this->equalTo($this->token))
->will($this->throwException($exception)) ->willThrowException($exception)
; ;
$this->tokenStorage->expects($this->once()) $this->tokenStorage->expects($this->once())

View File

@ -200,7 +200,7 @@ class HttpUtilsTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('match') ->method('match')
->with('/') ->with('/')
->will($this->throwException(new ResourceNotFoundException())) ->willThrowException(new ResourceNotFoundException())
; ;
$utils = new HttpUtils(null, $urlMatcher); $utils = new HttpUtils(null, $urlMatcher);
@ -215,7 +215,7 @@ class HttpUtilsTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('matchRequest') ->method('matchRequest')
->with($request) ->with($request)
->will($this->throwException(new MethodNotAllowedException(array()))) ->willThrowException(new MethodNotAllowedException(array()))
; ;
$utils = new HttpUtils(null, $urlMatcher); $utils = new HttpUtils(null, $urlMatcher);
@ -260,7 +260,7 @@ class HttpUtilsTest extends TestCase
$urlMatcher $urlMatcher
->expects($this->any()) ->expects($this->any())
->method('match') ->method('match')
->will($this->throwException(new \RuntimeException())) ->willThrowException(new \RuntimeException())
; ;
$utils = new HttpUtils(null, $urlMatcher); $utils = new HttpUtils(null, $urlMatcher);

View File

@ -65,7 +65,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$tokenProvider $tokenProvider
->expects($this->once()) ->expects($this->once())
->method('loadTokenBySeries') ->method('loadTokenBySeries')
->will($this->throwException(new TokenNotFoundException('Token not found.'))) ->willThrowException(new TokenNotFoundException('Token not found.'))
; ;
$service->setTokenProvider($tokenProvider); $service->setTokenProvider($tokenProvider);
@ -91,7 +91,7 @@ class PersistentTokenBasedRememberMeServicesTest extends TestCase
$userProvider $userProvider
->expects($this->once()) ->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->will($this->throwException(new UsernameNotFoundException('user not found'))) ->willThrowException(new UsernameNotFoundException('user not found'))
; ;
$this->assertNull($service->autoLogin($request)); $this->assertNull($service->autoLogin($request));

View File

@ -49,7 +49,7 @@ class TokenBasedRememberMeServicesTest extends TestCase
$userProvider $userProvider
->expects($this->once()) ->expects($this->once())
->method('loadUserByUsername') ->method('loadUserByUsername')
->will($this->throwException(new UsernameNotFoundException('user not found'))) ->willThrowException(new UsernameNotFoundException('user not found'))
; ;
$this->assertNull($service->autoLogin($request)); $this->assertNull($service->autoLogin($request));