Skip to content

Commit 245efc4

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 485d00c + a3f4282 commit 245efc4

22 files changed

+101
-101
lines changed

Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class AuthenticationProviderManagerTest extends TestCase
2626
{
2727
public function testAuthenticateWithoutProviders()
2828
{
29-
$this->expectException('InvalidArgumentException');
29+
$this->expectException(\InvalidArgumentException::class);
3030
new AuthenticationProviderManager([]);
3131
}
3232

3333
public function testAuthenticateWithProvidersWithIncorrectInterface()
3434
{
35-
$this->expectException('InvalidArgumentException');
35+
$this->expectException(\InvalidArgumentException::class);
3636
(new AuthenticationProviderManager([
3737
new \stdClass(),
3838
]))->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
@@ -45,7 +45,7 @@ public function testAuthenticateWhenNoProviderSupportsToken()
4545
]);
4646

4747
try {
48-
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
48+
$manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock());
4949
$this->fail();
5050
} catch (ProviderNotFoundException $e) {
5151
$this->assertSame($token, $e->getToken());
@@ -54,7 +54,7 @@ public function testAuthenticateWhenNoProviderSupportsToken()
5454

5555
public function testAuthenticateWhenProviderReturnsAccountStatusException()
5656
{
57-
$secondAuthenticationProvider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
57+
$secondAuthenticationProvider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock();
5858

5959
$manager = new AuthenticationProviderManager([
6060
$this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AccountStatusException'),
@@ -65,7 +65,7 @@ public function testAuthenticateWhenProviderReturnsAccountStatusException()
6565
$secondAuthenticationProvider->expects($this->never())->method('supports');
6666

6767
try {
68-
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
68+
$manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock());
6969
$this->fail();
7070
} catch (AccountStatusException $e) {
7171
$this->assertSame($token, $e->getToken());
@@ -79,7 +79,7 @@ public function testAuthenticateWhenProviderReturnsAuthenticationException()
7979
]);
8080

8181
try {
82-
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
82+
$manager->authenticate($token = $this->getMockBuilder(TokenInterface::class)->getMock());
8383
$this->fail();
8484
} catch (AuthenticationException $e) {
8585
$this->assertSame($token, $e->getToken());
@@ -90,26 +90,26 @@ public function testAuthenticateWhenOneReturnsAuthenticationExceptionButNotAll()
9090
{
9191
$manager = new AuthenticationProviderManager([
9292
$this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'),
93-
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
93+
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder(TokenInterface::class)->getMock()),
9494
]);
9595

96-
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
96+
$token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
9797
$this->assertSame($expected, $token);
9898
}
9999

100100
public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider()
101101
{
102-
$second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
102+
$second = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock();
103103
$second
104104
->expects($this->never())
105105
->method('supports')
106106
;
107107
$manager = new AuthenticationProviderManager([
108-
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
108+
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder(TokenInterface::class)->getMock()),
109109
$second,
110110
]);
111111

112-
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
112+
$token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
113113
$this->assertSame($expected, $token);
114114
}
115115

@@ -119,25 +119,25 @@ public function testEraseCredentialFlag()
119119
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
120120
]);
121121

122-
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
122+
$token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
123123
$this->assertEquals('', $token->getCredentials());
124124

125125
$manager = new AuthenticationProviderManager([
126126
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
127127
], false);
128128

129-
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
129+
$token = $manager->authenticate($this->getMockBuilder(TokenInterface::class)->getMock());
130130
$this->assertEquals('bar', $token->getCredentials());
131131
}
132132

133133
public function testAuthenticateDispatchesAuthenticationFailureEvent()
134134
{
135135
$token = new UsernamePasswordToken('foo', 'bar', 'key');
136-
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
136+
$provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock();
137137
$provider->expects($this->once())->method('supports')->willReturn(true);
138138
$provider->expects($this->once())->method('authenticate')->willThrowException($exception = new AuthenticationException());
139139

140-
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
140+
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
141141
$dispatcher
142142
->expects($this->once())
143143
->method('dispatch')
@@ -158,11 +158,11 @@ public function testAuthenticateDispatchesAuthenticationSuccessEvent()
158158
{
159159
$token = new UsernamePasswordToken('foo', 'bar', 'key');
160160

161-
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
161+
$provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock();
162162
$provider->expects($this->once())->method('supports')->willReturn(true);
163163
$provider->expects($this->once())->method('authenticate')->willReturn($token);
164164

165-
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
165+
$dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
166166
$dispatcher
167167
->expects($this->once())
168168
->method('dispatch')
@@ -176,7 +176,7 @@ public function testAuthenticateDispatchesAuthenticationSuccessEvent()
176176

177177
protected function getAuthenticationProvider($supports, $token = null, $exception = null)
178178
{
179-
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
179+
$provider = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface::class)->getMock();
180180
$provider->expects($this->once())
181181
->method('supports')
182182
->willReturn($supports)

Tests/Authentication/AuthenticationTrustResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ public function testisFullFledgedWithClassAsConstructorButStillExtending()
9191

9292
protected function getToken()
9393
{
94-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
94+
return $this->getMockBuilder(TokenInterface::class)->getMock();
9595
}
9696

9797
protected function getAnonymousToken()
9898
{
99-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(['', ''])->getMock();
99+
return $this->getMockBuilder(AnonymousToken::class)->setConstructorArgs(['', ''])->getMock();
100100
}
101101

102102
protected function getRememberMeToken()
103103
{
104-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock();
104+
return $this->getMockBuilder(RememberMeToken::class)->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock();
105105
}
106106

107107
protected function getResolver()

Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ public function testSupports()
2121
$provider = $this->getProvider('foo');
2222

2323
$this->assertTrue($provider->supports($this->getSupportedToken('foo')));
24-
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
24+
$this->assertFalse($provider->supports($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock()));
2525
}
2626

2727
public function testAuthenticateWhenTokenIsNotSupported()
2828
{
29-
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationException');
29+
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationException::class);
3030
$this->expectExceptionMessage('The token is not supported by this authentication provider.');
3131
$provider = $this->getProvider('foo');
3232

33-
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
33+
$provider->authenticate($this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock());
3434
}
3535

3636
public function testAuthenticateWhenSecretIsNotValid()
3737
{
38-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
38+
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
3939
$provider = $this->getProvider('foo');
4040

4141
$provider->authenticate($this->getSupportedToken('bar'));
@@ -51,7 +51,7 @@ public function testAuthenticate()
5151

5252
protected function getSupportedToken($secret)
5353
{
54-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock();
54+
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class)->setMethods(['getSecret'])->disableOriginalConstructor()->getMock();
5555
$token->expects($this->any())
5656
->method('getSecret')
5757
->willReturn($secret)

Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class LdapBindAuthenticationProviderTest extends TestCase
3030
{
3131
public function testEmptyPasswordShouldThrowAnException()
3232
{
33-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
33+
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
3434
$this->expectExceptionMessage('The presented password must not be empty.');
35-
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
35+
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
3636
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
37-
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
37+
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
3838

3939
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
4040
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@@ -45,11 +45,11 @@ public function testEmptyPasswordShouldThrowAnException()
4545

4646
public function testNullPasswordShouldThrowAnException()
4747
{
48-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
48+
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
4949
$this->expectExceptionMessage('The presented password must not be empty.');
50-
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
51-
$ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapInterface')->getMock();
52-
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
50+
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
51+
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
52+
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
5353

5454
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
5555
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@@ -60,7 +60,7 @@ public function testNullPasswordShouldThrowAnException()
6060

6161
public function testBindFailureShouldThrowAnException()
6262
{
63-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
63+
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
6464
$this->expectExceptionMessage('The presented password is invalid.');
6565
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
6666
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
@@ -182,7 +182,7 @@ public function testQueryWithUserForDn()
182182

183183
public function testEmptyQueryResultShouldThrowAnException()
184184
{
185-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
185+
$this->expectException(\Symfony\Component\Security\Core\Exception\BadCredentialsException::class);
186186
$this->expectExceptionMessage('The presented username is invalid.');
187187
$userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
188188

0 commit comments

Comments
 (0)