Skip to content

Commit a3f4282

Browse files
committed
Use ::class keyword when possible
1 parent 19d5c34 commit a3f4282

36 files changed

+218
-218
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
@@ -124,17 +124,17 @@ public function testisFullFledgedWithClassAsConstructorButStillExtending()
124124

125125
protected function getToken()
126126
{
127-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
127+
return $this->getMockBuilder(TokenInterface::class)->getMock();
128128
}
129129

130130
protected function getAnonymousToken()
131131
{
132-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(['', ''])->getMock();
132+
return $this->getMockBuilder(AnonymousToken::class)->setConstructorArgs(['', ''])->getMock();
133133
}
134134

135135
protected function getRememberMeToken()
136136
{
137-
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock();
137+
return $this->getMockBuilder(RememberMeToken::class)->setMethods(['setPersistent'])->disableOriginalConstructor()->getMock();
138138
}
139139

140140
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)

0 commit comments

Comments
 (0)