Skip to content

Commit 2363f8e

Browse files
[Tests] Replace setMethods() by onlyMethods() and addMethods()
1 parent aeb3330 commit 2363f8e

8 files changed

+10
-10
lines changed

Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
201201
} elseif (null !== $exception) {
202202
$provider->expects($this->once())
203203
->method('authenticate')
204-
->willThrowException($this->getMockBuilder($exception)->setMethods(null)->getMock())
204+
->willThrowException($this->getMockBuilder($exception)->onlyMethods([])->getMock())
205205
;
206206
}
207207

Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testAuthenticate()
5858

5959
protected function getSupportedToken($secret)
6060
{
61-
$token = $this->getMockBuilder(AnonymousToken::class)->setMethods(['getSecret'])->disableOriginalConstructor()->getMock();
61+
$token = $this->getMockBuilder(AnonymousToken::class)->onlyMethods(['getSecret'])->disableOriginalConstructor()->getMock();
6262
$token->expects($this->any())
6363
->method('getSecret')
6464
->willReturn($secret)

Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public function testPasswordUpgrades()
310310

311311
protected function getSupportedToken()
312312
{
313-
$mock = $this->getMockBuilder(UsernamePasswordToken::class)->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock();
313+
$mock = $this->getMockBuilder(UsernamePasswordToken::class)->onlyMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock();
314314
$mock
315315
->expects($this->any())
316316
->method('getProviderKey')

Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testAuthenticateWhenUserCheckerThrowsException()
9696

9797
protected function getSupportedToken($user = false, $credentials = false)
9898
{
99-
$token = $this->getMockBuilder(PreAuthenticatedToken::class)->setMethods(['getUser', 'getCredentials', 'getFirewallName'])->disableOriginalConstructor()->getMock();
99+
$token = $this->getMockBuilder(PreAuthenticatedToken::class)->onlyMethods(['getUser', 'getCredentials', 'getFirewallName'])->disableOriginalConstructor()->getMock();
100100
if (false !== $user) {
101101
$token->expects($this->once())
102102
->method('getUser')

Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function getSupportedToken($user = null, $secret = 'test')
108108
->willReturn([]);
109109
}
110110

111-
$token = $this->getMockBuilder(RememberMeToken::class)->setMethods(['getFirewallName'])->setConstructorArgs([$user, 'foo', $secret])->getMock();
111+
$token = $this->getMockBuilder(RememberMeToken::class)->onlyMethods(['getFirewallName'])->setConstructorArgs([$user, 'foo', $secret])->getMock();
112112
$token
113113
->expects($this->once())
114114
->method('getFirewallName')

Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function testAuthenticatePreservesOriginalToken()
232232

233233
protected function getSupportedToken()
234234
{
235-
$mock = $this->getMockBuilder(UsernamePasswordToken::class)->setMethods(['getCredentials', 'getFirewallName', 'getRoles'])->disableOriginalConstructor()->getMock();
235+
$mock = $this->getMockBuilder(UsernamePasswordToken::class)->onlyMethods(['getCredentials', 'getFirewallName'])->addMethods(['getRoles'])->disableOriginalConstructor()->getMock();
236236
$mock
237237
->expects($this->any())
238238
->method('getFirewallName')

Tests/Authentication/Token/Storage/UsageTrackingTokenStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testGetSetToken()
3131

3232
$request = new Request();
3333
$request->setSession($session);
34-
$requestStack = $this->getMockBuilder(RequestStack::class)->setMethods(['getSession'])->getMock();
34+
$requestStack = $this->getMockBuilder(RequestStack::class)->onlyMethods(['getSession'])->getMock();
3535
$requestStack->push($request);
3636
$requestStack->expects($this->any())->method('getSession')->willReturnCallback(function () use ($session, &$sessionAccess) {
3737
++$sessionAccess;

Tests/Authorization/TraceableAccessDecisionManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,17 @@ public function testAccessDecisionManagerCalledByVoter()
186186
{
187187
$voter1 = $this
188188
->getMockBuilder(VoterInterface::class)
189-
->setMethods(['vote'])
189+
->onlyMethods(['vote'])
190190
->getMock();
191191

192192
$voter2 = $this
193193
->getMockBuilder(VoterInterface::class)
194-
->setMethods(['vote'])
194+
->onlyMethods(['vote'])
195195
->getMock();
196196

197197
$voter3 = $this
198198
->getMockBuilder(VoterInterface::class)
199-
->setMethods(['vote'])
199+
->onlyMethods(['vote'])
200200
->getMock();
201201

202202
$sut = new TraceableAccessDecisionManager(new AccessDecisionManager([$voter1, $voter2, $voter3]));

0 commit comments

Comments
 (0)