8000 Don't call createMock with an array of interfaces. · symfony/symfony@a8e762d · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8e762d

Browse files
committed
Don't call createMock with an array of interfaces.
1 parent f0bf853 commit a8e762d

File tree

6 files changed

+58
-12
lines changed

6 files changed

+58
-12
lines changed

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty
7070
{
7171
$user = new User(1, 1, 'user1');
7272

73-
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
73+
$repository = $this->createMock(UserLoaderRepository::class);
7474
$repository
7575
->expects($this->once())
7676
->method('loadUserByUsername')
@@ -156,7 +156,7 @@ public function testSupportProxy()
156156

157157
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
158158
{
159-
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
159+
$repository = $this->createMock(UserLoaderRepository::class);
160160
$repository->expects($this->once())
161161
->method('loadUserByUsername')
162162
->with('name')
@@ -189,7 +189,7 @@ public function testPasswordUpgrades()
189189
{
190190
$user = new User(1, 1, 'user1');
191191

192-
$repository = $this->createMock([interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class, PasswordUpgraderInterface::class]);
192+
$repository = $this->createMock(PasswordUpgraderRepository::class);
193193
$repository->expects($this->once())
194194
->method('upgradePassword')
195195
->with($user, 'foobar');
@@ -233,3 +233,11 @@ private function createSchema($em)
233233
]);
234234
}
235235
}
236+
237+
abstract class UserLoaderRepository implements ObjectRepository, UserLoaderInterface
238+
{
239+
}
240+
241+
abstract class PasswordUpgraderRepository implements ObjectRepository, PasswordUpgraderInterface
242+
{
243+
}

src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1717
use Symfony\Component\Cache\Adapter\ChainAdapter;
1818
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
19-
use Symfony\Component\Cache\PruneableInterface;
2019
use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
20+
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
2121

2222
/**
2323
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -189,7 +189,7 @@ public function testMultipleCachesExpirationWhenCommonTtlIsSet()
189189

190190
private function getPruneableMock(): AdapterInterface
191191
{
192-
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
192+
$pruneable = $this->createMock(Pruna E7EE bleAdapter::class);
193193

194194
$pruneable
195195
->expects($this->atLeastOnce())
@@ -201,7 +201,7 @@ private function getPruneableMock(): AdapterInterface
201201

202202
private function getFailingPruneableMock(): AdapterInterface
203203
{
204-
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
204+
$pruneable = $this->createMock(PrunableAdapter::class);
205205

206206
$pruneable
207207
->expects($this->atLeastOnce())

src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1919
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
2020
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
21-
use Symfony\Component\Cache\PruneableInterface;
21+
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
2222
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
2323

2424
/**
@@ -204,7 +204,7 @@ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags
204204
*/
205205
private function getPruneableMock(): AdapterInterface
206206
{
207-
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
207+
$pruneable = $this->createMock(PrunableAdapter::class);
208208

209209
$pruneable
210210
->expects($this->atLeastOnce())
@@ -216,7 +216,7 @@ private function getPruneableMock(): AdapterInterface
216216

217217
private function getFailingPruneableMock(): AdapterInterface
218218
{
219-
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
219+
$pruneable = $this->createMock(PrunableAdapter::class);
220220

221221
$pruneable
222222
->expects($this->atLeastOnce())
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Tests\Fixtures;
13+
14+
use Symfony\Component\Cache\Adapter\AdapterInterface;
15+
use Symfony\Component\Cache\PruneableInterface;
16+
17+
abstract class PrunableAdapter implements AdapterInterface, PruneableInterface
18+
{
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Cache\Tests\Fixtures;
13+
14+
use Psr\SimpleCache\CacheInterface;
15+
use Symfony\Component\Cache\PruneableInterface;
16+
17+
abstract class PrunableCache implements CacheInterface, PruneableInterface
18+
{
19+
}

src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Symfony\Component\Cache\Tests\Simple;
1313

1414
use Psr\SimpleCache\CacheInterface;
15-
use Symfony\Component\Cache\PruneableInterface;
1615
use Symfony\Component\Cache\Simple\ArrayCache;
1716
use Symfony\Component\Cache\Simple\ChainCache;
1817
use Symfony\Component\Cache\Simple\FilesystemCache;
18+
use Symfony\Component\Cache\Tests\Fixtures\PrunableCache;
1919

2020
/**
2121
* @group time-sensitive
@@ -65,7 +65,7 @@ public function testPrune()
6565

6666
private function getPruneableMock(): CacheInterface
6767
{
68-
$pruneable = $this->createMock([CacheInterface::class, PruneableInterface::class]);
68+
$pruneable = $this->createMock(PrunableCache::class);
6969

7070
$pruneable
7171
->expects($this->atLeastOnce())
@@ -77,7 +77,7 @@ private function getPruneableMock(): CacheInterface
7777

7878
private function getFailingPruneableMock(): CacheInterface
7979
{
80-
$pruneable = $this->createMock([CacheInterface::class, PruneableInterface::class]);
80+
$pruneable = $this->createMock(PrunableCache::class);
8181

8282
$pruneable
8383
->expects($this->atLeastOnce())

0 commit comments

Comments
 (0)
0