Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 90bb3ea

Browse files
committed
fixed obsolete getMock() usage
1 parent 9ba5cbe commit 90bb3ea

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

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)