Skip to content

Commit be6feea

Browse files
gmponosfabpot
authored andcommitted
[Tests] Change to willThrowException
1 parent 6f818c8 commit be6feea

9 files changed

+23
-23
lines changed

Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
188188
} elseif (null !== $exception) {
189189
$provider->expects($this->once())
190190
->method('authenticate')
191-
->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
191+
->willThrowException($this->getMockBuilder($exception)->setMethods(null)->getMock())
192192
;
193193
}
194194

Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testRetrieveUserWhenUsernameIsNotFound()
3838
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
3939
$userProvider->expects($this->once())
4040
->method('loadUserByUsername')
41-
->will($this->throwException(new UsernameNotFoundException()))
41+
->willThrowException(new UsernameNotFoundException())
4242
;
4343

4444
$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 @@ public function testRetrieveUserWhenAnExceptionOccurs()
5656
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
5757
$userProvider->expects($this->once())
5858
->method('loadUserByUsername')
59-
->will($this->throwException(new \RuntimeException()))
59+
->willThrowException(new \RuntimeException())
6060
;
6161

6262
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());

Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testBindFailureShouldThrowAnException()
7373
$ldap
7474
->expects($this->once())
7575
->method('bind')
76-
->will($this->throwException(new ConnectionException()))
76+
->willThrowException(new ConnectionException())
7777
;
7878
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
7979

Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testAuthenticateWhenUserCheckerThrowsException()
8585
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
8686
$userChecker->expects($this->once())
8787
->method('checkPostAuth')
88-
->will($this->throwException(new LockedException()))
88+
->willThrowException(new LockedException())
8989
;
9090

9191
$provider = $this->getProvider($user, $userChecker);

Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testAuthenticateWhenPreChecksFails()
5757
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
5858
$userChecker->expects($this->once())
5959
->method('checkPreAuth')
60-
->will($this->throwException(new DisabledException()));
60+
->willThrowException(new DisabledException());
6161

6262
$provider = $this->getProvider($userChecker);
6363

Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testAuthenticateWhenPreChecksFails()
3434
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
3535
$userChecker->expects($this->once())
3636
->method('checkPreAuth')
37-
->will($this->throwException(new DisabledException()));
37+
->willThrowException(new DisabledException());
3838

3939
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
4040
$authenticator->expects($this->once())
@@ -61,7 +61,7 @@ public function testAuthenticateWhenPostChecksFails()
6161
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
6262
$userChecker->expects($this->once())
6363
->method('checkPostAuth')
64-
->will($this->throwException(new LockedException()));
64+
->willThrowException(new LockedException());
6565

6666
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
6767
$authenticator->expects($this->once())

Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testAuthenticateWhenUsernameIsNotFound()
4848
$provider = $this->getProvider(false, false);
4949
$provider->expects($this->once())
5050
->method('retrieveUser')
51-
->will($this->throwException(new UsernameNotFoundException()))
51+
->willThrowException(new UsernameNotFoundException())
5252
;
5353

5454
$provider->authenticate($this->getSupportedToken());
@@ -62,7 +62,7 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
6262
$provider = $this->getProvider(false, true);
6363
$provider->expects($this->once())
6464
->method('retrieveUser')
65-
->will($this->throwException(new UsernameNotFoundException()))
65+
->willThrowException(new UsernameNotFoundException())
6666
;
6767

6868
$provider->authenticate($this->getSupportedToken());
@@ -90,7 +90,7 @@ public function testAuthenticateWhenPreChecksFails()
9090
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
9191
$userChecker->expects($this->once())
9292
->method('checkPreAuth')
93-
->will($this->throwException(new CredentialsExpiredException()))
93+
->willThrowException(new CredentialsExpiredException())
9494
;
9595

9696
$provider = $this->getProvider($userChecker);
@@ -110,7 +110,7 @@ public function testAuthenticateWhenPostChecksFails()
110110
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
111111
$userChecker->expects($this->once())
112112
->method('checkPostAuth')
113-
->will($this->throwException(new AccountExpiredException()))
113+
->willThrowException(new AccountExpiredException())
114114
;
115115

116116
$provider = $this->getProvider($userChecker);
@@ -135,7 +135,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
135135
;
136136
$provider->expects($this->once())
137137
->method('checkAuthentication')
138-
->will($this->throwException(new BadCredentialsException()))
138+
->willThrowException(new BadCredentialsException())
139139
;
140140

141141
$provider->authenticate($this->getSupportedToken());
@@ -154,7 +154,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFailsWithHideFalse()
154154
;
155155
$provider->expects($this->once())
156156
->method('checkAuthentication')
157-
->will($this->throwException(new BadCredentialsException('Foo')))
157+
->willThrowException(new BadCredentialsException('Foo'))
158158
;
159159

160160
$provider->authenticate($this->getSupportedToken());

Tests/User/ChainUserProviderTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testLoadUserByUsername()
2525
->expects($this->once())
2626
->method('loadUserByUsername')
2727
->with($this->equalTo('foo'))
28-
->will($this->throwException(new UsernameNotFoundException('not found')))
28+
->willThrowException(new UsernameNotFoundException('not found'))
2929
;
3030

3131
$provider2 = $this->getProvider();
@@ -50,15 +50,15 @@ public function testLoadUserByUsernameThrowsUsernameNotFoundException()
5050
->expects($this->once())
5151
->method('loadUserByUsername')
5252
->with($this->equalTo('foo'))
53-
->will($this->throwException(new UsernameNotFoundException('not found')))
53+
->willThrowException(new UsernameNotFoundException('not found'))
5454
;
5555

5656
$provider2 = $this->getProvider();
5757
$provider2
5858
->expects($this->once())
5959
->method('loadUserByUsername')
6060
->with($this->equalTo('foo'))
61-
->will($this->throwException(new UsernameNotFoundException('not found')))
61+
->willThrowException(new UsernameNotFoundException('not found'))
6262
;
6363

6464
$provider = new ChainUserProvider(array($provider1, $provider2));
@@ -71,7 +71,7 @@ public function testRefreshUser()
7171
$provider1
7272
->expects($this->once())
7373
->method('refreshUser')
74-
->will($this->throwException(new UnsupportedUserException('unsupported')))
74+
->willThrowException(new UnsupportedUserException('unsupported'))
7575
;
7676

7777
$provider2 = $this->getProvider();
@@ -91,7 +91,7 @@ public function testRefreshUserAgain()
9191
$provider1
9292
->expects($this->once())
9393
->method('refreshUser')
94-
->will($this->throwException(new UsernameNotFoundException('not found')))
94+
->willThrowException(new UsernameNotFoundException('not found'))
9595
;
9696

9797
$provider2 = $this->getProvider();
@@ -114,14 +114,14 @@ public function testRefreshUserThrowsUnsupportedUserException()
114114
$provider1
115115
->expects($this->once())
116116
->method('refreshUser')
117-
->will($this->throwException(new UnsupportedUserException('unsupported')))
117+
->willThrowException(new UnsupportedUserException('unsupported'))
118118
;
119119

120120
$provider2 = $this->getProvider();
121121
$provider2
122122
->expects($this->once())
123123
->method('refreshUser')
124-
->will($this->throwException(new UnsupportedUserException('unsupported')))
124+
->willThrowException(new UnsupportedUserException('unsupported'))
125125
;
126126

127127
$provider = new ChainUserProvider(array($provider1, $provider2));
@@ -178,7 +178,7 @@ public function testAcceptsTraversable()
178178
$provider1
179179
->expects($this->once())
180180
->method('refreshUser')
181-
->will($this->throwException(new UnsupportedUserException('unsupported')))
181+
->willThrowException(new UnsupportedUserException('unsupported'))
182182
;
183183

184184
$provider2 = $this->getProvider();

Tests/User/LdapUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testLoadUserByUsernameFailsIfCantConnectToLdap()
3333
$ldap
3434
->expects($this->once())
3535
->method('bind')
36-
->will($this->throwException(new ConnectionException()))
36+
->willThrowException(new ConnectionException())
3737
;
3838

3939
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com');

0 commit comments

Comments
 (0)