Skip to content

Commit 2819a57

Browse files
committed
fixed obsolete getMock() usage
1 parent 6126018 commit 2819a57

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public function testGetTokenNoTokenStorage()
3333

3434
public function testGetTokenNoToken()
3535
{
36-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
36+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
3737
$this->container->set('security.token_storage', $tokenStorage);
3838
$this->assertNull($this->globals->getToken());
3939
}
4040

4141
public function testGetToken()
4242
{
43-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
43+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
4444

4545
$this->container->set('security.token_storage', $tokenStorage);
4646

src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Psr6CacheClearerTest extends \PHPUnit_Framework_TestCase
1818
{
1919
public function testClearPoolsInjectedInConstructor()
2020
{
21-
$pool = $this->getMock(CacheItemPoolInterface::class);
21+
$pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
2222
$pool
2323
->expects($this->once())
2424
->method('clear');
@@ -28,7 +28,7 @@ public function testClearPoolsInjectedInConstructor()
2828

2929
public function testClearPool()
3030
{
31-
$pool = $this->getMock(CacheItemPoolInterface::class);
31+
$pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
3232
$pool
3333
->expects($this->once())
3434
->method('clear');
@@ -51,12 +51,12 @@ public function testClearPoolThrowsExceptionOnUnreferencedPool()
5151
*/
5252
public function testClearPoolsInjectedByAdder()
5353
{
54-
$pool1 = $this->getMock(CacheItemPoolInterface::class);
54+
$pool1 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
5555
$pool1
5656
->expects($this->once())
5757
->method('clear');
5858

59-
$pool2 = $this->getMock(CacheItemPoolInterface::class);
59+
$pool2 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
6060
$pool2
6161
->expects($this->once())
6262
->method('clear');

src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function testWithBadRequest()
165165
{
166166
$requestStack = new RequestStack();
167167

168-
$requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
168+
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
169169
$requestMatcher->expects($this->never())->method('matchRequest');
170170

171171
$dispatcher = new EventDispatcher();

src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testSwitchUserIsDisallowed()
233233
public function testSwitchUser()
234234
{
235235
$token = $this->getToken(array(new Role('the role')));
236-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
236+
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
237237
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
238238

239239
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
@@ -263,7 +263,7 @@ public function testSwitchUser()
263263
public function testSwitchUserKeepsOtherQueryStringParameters()
264264
{
265265
$token = $this->getToken(array(new Role('the role')));
266-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
266+
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
267267
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
268268

269269
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));

src/Symfony/Component/Security/Tests/Http/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ class UsernamePasswordJsonAuthenticationListenerTest extends \PHPUnit_Framework_
3535

3636
private function createListener(array $options = array(), $success = true)
3737
{
38-
$tokenStorage = $this->getMock(TokenStorageInterface::class);
39-
$authenticationManager = $this->getMock(AuthenticationManagerInterface::class);
38+
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
39+
$authenticationManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock();
4040

4141
if ($success) {
4242
$authenticationManager->method('authenticate')->willReturn(true);
4343
} else {
4444
$authenticationManager->method('authenticate')->willThrowException(new AuthenticationException());
4545
}
4646

47-
$authenticationSuccessHandler = $this->getMock(AuthenticationSuccessHandlerInterface::class);
47+
$authenticationSuccessHandler = $this->getMockBuilder(AuthenticationSuccessHandlerInterface::class)->getMock();
4848
$authenticationSuccessHandler->method('onAuthenticationSuccess')->willReturn(new Response('ok'));
49-
$authenticationFailureHandler = $this->getMock(AuthenticationFailureHandlerInterface::class);
49+
$authenticationFailureHandler = $this->getMockBuilder(AuthenticationFailureHandlerInterface::class)->getMock();
5050
$authenticationFailureHandler->method('onAuthenticationFailure')->willReturn(new Response('ko'));
5151

5252
$this->listener = new UsernamePasswordJsonAuthenticationListener($tokenStorage, $authenticationManager, 'providerKey', $authenticationSuccessHandler, $authenticationFailureHandler, $options);
@@ -56,7 +56,7 @@ public function testHandleSuccess()
5656
{
5757
$this->createListener();
5858
$request = new Request(array(), array(), array(), array(), array(), array(), '{"username": "dunglas", "password": "foo"}');
59-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
59+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
6060

6161
$this->listener->handle($event);
6262
$this->assertEquals('ok', $event->getResponse()->getContent());
@@ -66,7 +66,7 @@ public function testHandleFailure()
6666
{
6767
$this->createListener(array(), false);
6868
$request = new Request(array(), array(), array(), array(), array(), array(), '{"username": "dunglas", "password": "foo"}');
69-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
69+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
7070

7171
$this->listener->handle($event);
7272
$this->assertEquals('ko', $event->getResponse()->getContent());
@@ -76,7 +76,7 @@ public function testUsePath()
7676
{
7777
$this->createListener(array('username_path' => 'user.login', 'password_path' => 'user.pwd'));
7878
$request = new Request(array(), array(), array(), array(), array(), array(), '{"user": {"login": "dunglas", "pwd": "foo"}}');
79-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
79+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
8080

8181
$this->listener->handle($event);
8282
$this->assertEquals('ok', $event->getResponse()->getContent());
@@ -89,7 +89,7 @@ public function testAttemptAuthenticationNoUsername()
8989
{
9090
$this->createListener();
9191
$request = new Request(array(), array(), array(), array(), array(), array(), '{"usr": "dunglas", "password": "foo"}');
92-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
92+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
9393

9494
$this->listener->handle($event);
9595
}
@@ -101,7 +101,7 @@ public function testAttemptAuthenticationNoPassword()
101101
{
102102
$this->createListener();
103103
$request = new Request(array(), array(), array(), array(), array(), array(), '{"username": "dunglas", "pass": "foo"}');
104-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
104+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
105105

106106
$this->listener->handle($event);
107107
}
@@ -113,7 +113,7 @@ public function testAttemptAuthenticationUsernameNotAString()
113113
{
114114
$this->createListener();
115115
$request = new Request(array(), array(), array(), array(), array(), array(), '{"username": 1, "password": "foo"}');
116-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
116+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
117117

118118
$this->listener->handle($event);
119119
}
@@ -125,7 +125,7 @@ public function testAttemptAuthenticationPasswordNotAString()
125125
{
126126
$this->createListener();
127127
$request = new Request(array(), array(), array(), array(), array(), array(), '{"username": "dunglas", "password": 1}');
128-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
128+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
129129

130130
$this->listener->handle($event);
131131
}
@@ -138,7 +138,7 @@ public function testAttemptAuthenticationUsernameTooLong()
138138
$this->createListener();
139139
$username = str_repeat('x', Security::MAX_USERNAME_LENGTH + 1);
140140
$request = new Request(array(), array(), array(), array(), array(), array(), sprintf('{"username": "%s", "password": 1}', $username));
141-
$event = new GetResponseEvent($this->getMock(KernelInterface::class), $request, KernelInterface::MASTER_REQUEST);
141+
$event = new GetResponseEvent($this->getMockBuilder(KernelInterface::class)->getMock(), $request, KernelInterface::MASTER_REQUEST);
142142

143143
$this->listener->handle($event);
144144
}

0 commit comments

Comments
 (0)