Skip to content

Commit b15a6a0

Browse files
Remove calls to getMockForAbstractClass()
1 parent 2c17186 commit b15a6a0

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ protected function getProvider($userChecker = false, $hide = true)
250250
$userChecker = $this->createMock(UserCheckerInterface::class);
251251
}
252252

253-
return $this->getMockForAbstractClass(UserAuthenticationProvider::class, [$userChecker, 'key', $hide]);
253+
return $this->getMockBuilder(UserAuthenticationProvider::class)
254+
->setConstructorArgs([$userChecker, 'key', $hide])
255+
->onlyMethods(['retrieveUser', 'checkAuthentication'])
256+
->getMock();
254257
}
255258
}

Tests/Authorization/AccessDecisionManagerTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ public static function getStrategyTests(): array
179179
public function testCacheableVoters()
180180
{
181181
$token = $this->createMock(TokenInterface::class);
182-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
182+
$voter = $this->createMock(CacheableVoterInterface::class);
183+
183184
$voter
184185
->expects($this->once())
185186
->method('supportsAttribute')
@@ -203,7 +204,7 @@ public function testCacheableVoters()
203204
public function testCacheableVotersIgnoresNonStringAttributes()
204205
{
205206
$token = $this->createMock(TokenInterface::class);
206-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
207+
$voter = $this->createMock(CacheableVoterInterface::class);
207208
$voter
208209
->expects($this->never())
209210
->method('supportsAttribute');
@@ -225,7 +226,7 @@ public function testCacheableVotersIgnoresNonStringAttributes()
225226
public function testCacheableVotersWithMultipleAttributes()
226227
{
227228
$token = $this->createMock(TokenInterface::class);
228-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
229+
$voter = $this->createMock(CacheableVoterInterface::class);
229230
$voter
230231
->expects($this->exactly(2))
231232
->method('supportsAttribute')
@@ -258,7 +259,7 @@ public function testCacheableVotersWithMultipleAttributes()
258259
public function testCacheableVotersWithEmptyAttributes()
259260
{
260261
$token = $this->createMock(TokenInterface::class);
261-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
262+
$voter = $this->createMock(CacheableVoterInterface::class);
262263
$voter
263264
->expects($this->never())
264265
->method('supportsAttribute');
@@ -280,7 +281,7 @@ public function testCacheableVotersWithEmptyAttributes()
280281
public function testCacheableVotersSupportsMethodsCalledOnce()
281282
{
282283
$token = $this->createMock(TokenInterface::class);
283-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
284+
$voter = $this->createMock(CacheableVoterInterface::class);
284285
$voter
285286
->expects($this->once())
286287
->method('supportsAttribute')
@@ -305,7 +306,7 @@ public function testCacheableVotersSupportsMethodsCalledOnce()
305306
public function testCacheableVotersNotCalled()
306307
{
307308
$token = $this->createMock(TokenInterface::class);
308-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
309+
$voter = $this->createMock(CacheableVoterInterface::class);
309310
$voter
310311
->expects($this->once())
311312
->method('supportsAttribute')
@@ -325,7 +326,7 @@ public function testCacheableVotersNotCalled()
325326
public function testCacheableVotersWithMultipleAttributesAndNonString()
326327
{
327328
$token = $this->createMock(TokenInterface::class);
328-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
329+
$voter = $this->createMock(CacheableVoterInterface::class);
329330
$voter
330331
->expects($this->once())
331332
->method('supportsAttribute')

Tests/Authorization/Voter/TraceableVoterTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ class TraceableVoterTest extends TestCase
2323
{
2424
public function testGetDecoratedVoterClass()
2525
{
26-
$voter = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
26+
$voter = $this->createStub(VoterInterface::class);
2727

28-
$sut = new TraceableVoter($voter, $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass());
28+
$sut = new TraceableVoter($voter, $this->createStub(EventDispatcherInterface::class));
2929
$this->assertSame($voter, $sut->getDecoratedVoter());
3030
}
3131

3232
public function testVote()
3333
{
34-
$voter = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
34+
$voter = $this->createMock(VoterInterface::class);
3535

36-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
37-
$token = $this->getMockBuilder(TokenInterface::class)->getMockForAbstractClass();
36+
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
37+
$token = $this->createStub(TokenInterface::class);
3838

3939
$voter
4040
->expects($this->once())
@@ -55,8 +55,8 @@ public function testVote()
5555

5656
public function testSupportsAttributeOnCacheable()
5757
{
58-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
59-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
58+
$voter = $this->createMock(CacheableVoterInterface::class);
59+
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
6060

6161
$voter
6262
->expects($this->once())
@@ -71,8 +71,8 @@ public function testSupportsAttributeOnCacheable()
7171

7272
public function testSupportsTypeOnCacheable()
7373
{
74-
$voter = $this->getMockBuilder(CacheableVoterInterface::class)->getMockForAbstractClass();
75-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
74+
$voter = $this->createMock(CacheableVoterInterface::class);
75+
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
7676

7777
$voter
7878
->expects($this->once())
@@ -87,8 +87,8 @@ public function testSupportsTypeOnCacheable()
8787

8888
public function testSupportsAttributeOnNonCacheable()
8989
{
90-
$voter = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
91-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
90+
$voter = $this->createStub(VoterInterface::class);
91+
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
9292

9393
$sut = new TraceableVoter($voter, $eventDispatcher);
9494

@@ -97,8 +97,8 @@ public function testSupportsAttributeOnNonCacheable()
9797

9898
public function testSupportsTypeOnNonCacheable()
9999
{
100-
$voter = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
101-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
100+
$voter = $this->createStub(VoterInterface::class);
101+
$eventDispatcher = $this->createStub(EventDispatcherInterface::class);
102102

103103
$sut = new TraceableVoter($voter, $eventDispatcher);
104104

Tests/User/ChainUserProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ public function testPasswordUpgrades()
252252
{
253253
$user = new InMemoryUser('user', 'pwd');
254254

255-
$provider1 = $this->getMockForAbstractClass(MigratingProvider::class);
255+
$provider1 = $this->createMock(MigratingProvider::class);
256256
$provider1
257257
->expects($this->once())
258258
->method('upgradePassword')
259259
->willThrowException(new UnsupportedUserException('unsupported'))
260260
;
261261

262-
$provider2 = $this->getMockForAbstractClass(MigratingProvider::class);
262+
$provider2 = $this->createMock(MigratingProvider::class);
263263
$provider2
264264
->expects($this->once())
265265
->method('upgradePassword')

0 commit comments

Comments
 (0)