Skip to content

Commit dc85438

Browse files
committed
fixed obsolete getMock() usage
1 parent b869fd9 commit dc85438

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

Tests/Firewall/AnonymousAuthenticationListenerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
1818
{
1919
public function testHandleWithTokenStorageHavingAToken()
2020
{
21-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
21+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
2222
$tokenStorage
2323
->expects($this->any())
2424
->method('getToken')
25-
->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
25+
->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()))
2626
;
2727
$tokenStorage
2828
->expects($this->never())
2929
->method('setToken')
3030
;
3131

32-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
32+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
3333
$authenticationManager
3434
->expects($this->never())
3535
->method('authenticate')
3636
;
3737

3838
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager);
39-
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
39+
$listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock());
4040
}
4141

4242
public function testHandleWithTokenStorageHavingNoToken()
4343
{
44-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
44+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
4545
$tokenStorage
4646
->expects($this->any())
4747
->method('getToken')
@@ -50,7 +50,7 @@ public function testHandleWithTokenStorageHavingNoToken()
5050

5151
$anonymousToken = new AnonymousToken('TheSecret', 'anon.', array());
5252

53-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
53+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
5454
$authenticationManager
5555
->expects($this->once())
5656
->method('authenticate')
@@ -67,21 +67,21 @@ public function testHandleWithTokenStorageHavingNoToken()
6767
;
6868

6969
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', null, $authenticationManager);
70-
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
70+
$listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock());
7171
}
7272

7373
public function testHandledEventIsLogged()
7474
{
75-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
76-
$logger = $this->getMock('Psr\Log\LoggerInterface');
75+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
76+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
7777
$logger->expects($this->once())
7878
->method('info')
7979
->with('Populated the TokenStorage with an anonymous Token.')
8080
;
8181

82-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
82+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
8383

8484
$listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager);
85-
$listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false));
85+
$listener->handle($this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock());
8686
}
8787
}

Tests/Firewall/DigestAuthenticationListenerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public function testHandleWithValidDigest()
3434

3535
$entryPoint = new DigestAuthenticationEntryPoint($realm, $secret);
3636

37-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
37+
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
3838
$user->method('getPassword')->willReturn($password);
3939

4040
$providerKey = 'TheProviderKey';
4141

42-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
42+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
4343
$tokenStorage
4444
->expects($this->once())
4545
->method('getToken')
@@ -51,12 +51,12 @@ public function testHandleWithValidDigest()
5151
->with($this->equalTo(new UsernamePasswordToken($user, $password, $providerKey)))
5252
;
5353

54-
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
54+
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
5555
$userProvider->method('loadUserByUsername')->willReturn($user);
5656

5757
$listener = new DigestAuthenticationListener($tokenStorage, $userProvider, $providerKey, $entryPoint);
5858

59-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
59+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
6060
$event
6161
->expects($this->any())
6262
->method('getRequest')

Tests/Firewall/SimplePreAuthenticationListenerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testHandle()
4242
->will($this->returnValue($this->token))
4343
;
4444

45-
$simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface');
45+
$simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock();
4646
$simpleAuthenticator
4747
->expects($this->once())
4848
->method('createToken')
@@ -79,7 +79,7 @@ public function testHandlecatchAuthenticationException()
7979
->with($this->equalTo(null))
8080
;
8181

82-
$simpleAuthenticator = $this->getMock('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface');
82+
$simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock();
8383
$simpleAuthenticator
8484
->expects($this->once())
8585
->method('createToken')
@@ -99,20 +99,20 @@ protected function setUp()
9999
->getMock()
100100
;
101101

102-
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
102+
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
103103

104104
$this->request = new Request(array(), array(), array(), array(), array(), array());
105105

106-
$this->event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
106+
$this->event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
107107
$this->event
108108
->expects($this->any())
109109
->method('getRequest')
110110
->will($this->returnValue($this->request))
111111
;
112112

113-
$this->logger = $this->getMock('Psr\Log\LoggerInterface');
114-
$this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
115-
$this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
113+
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
114+
$this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
115+
$this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
116116
}
117117

118118
protected function tearDown()

0 commit comments

Comments
 (0)