Don't call createMock with an array of interfaces.

This commit is contained in:
Alexander M. Turek 2020-09-06 20:56:21 +02:00
parent f0bf853a86
commit a8e762d8c3
6 changed files with 58 additions and 12 deletions

View File

@ -70,7 +70,7 @@ class EntityUserProviderTest extends TestCase
{
$user = new User(1, 1, 'user1');
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
$repository = $this->createMock(UserLoaderRepository::class);
$repository
->expects($this->once())
->method('loadUserByUsername')
@ -156,7 +156,7 @@ class EntityUserProviderTest extends TestCase
public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided()
{
$repository = $this->createMock([ObjectRepository::class, UserLoaderInterface::class]);
$repository = $this->createMock(UserLoaderRepository::class);
$repository->expects($this->once())
->method('loadUserByUsername')
->with('name')
@ -189,7 +189,7 @@ class EntityUserProviderTest extends TestCase
{
$user = new User(1, 1, 'user1');
$repository = $this->createMock([interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class, PasswordUpgraderInterface::class]);
$repository = $this->createMock(PasswordUpgraderRepository::class);
$repository->expects($this->once())
->method('upgradePassword')
->with($user, 'foobar');
@ -233,3 +233,11 @@ class EntityUserProviderTest extends TestCase
]);
}
}
abstract class UserLoaderRepository implements ObjectRepository, UserLoaderInterface
{
}
abstract class PasswordUpgraderRepository implements ObjectRepository, PasswordUpgraderInterface
{
}

View File

@ -16,8 +16,8 @@ use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\ChainAdapter;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter;
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
/**
* @author Kévin Dunglas <dunglas@gmail.com>
@ -189,7 +189,7 @@ class ChainAdapterTest extends AdapterTestCase
private function getPruneableMock(): AdapterInterface
{
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
$pruneable = $this->createMock(PrunableAdapter::class);
$pruneable
->expects($this->atLeastOnce())
@ -201,7 +201,7 @@ class ChainAdapterTest extends AdapterTestCase
private function getFailingPruneableMock(): AdapterInterface
{
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
$pruneable = $this->createMock(PrunableAdapter::class);
$pruneable
->expects($this->atLeastOnce())

View File

@ -18,7 +18,7 @@ use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
/**
@ -204,7 +204,7 @@ class TagAwareAdapterTest extends AdapterTestCase
*/
private function getPruneableMock(): AdapterInterface
{
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
$pruneable = $this->createMock(PrunableAdapter::class);
$pruneable
->expects($this->atLeastOnce())
@ -216,7 +216,7 @@ class TagAwareAdapterTest extends AdapterTestCase
private function getFailingPruneableMock(): AdapterInterface
{
$pruneable = $this->createMock([PruneableInterface::class, AdapterInterface::class]);
$pruneable = $this->createMock(PrunableAdapter::class);
$pruneable
->expects($this->atLeastOnce())

View File

@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Cache\Tests\Fixtures;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\PruneableInterface;
abstract class PrunableAdapter implements AdapterInterface, PruneableInterface
{
}

View File

@ -0,0 +1,19 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Cache\Tests\Fixtures;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\PruneableInterface;
abstract class PrunableCache implements CacheInterface, PruneableInterface
{
}

View File

@ -12,10 +12,10 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Component\Cache\Simple\ArrayCache;
use Symfony\Component\Cache\Simple\ChainCache;
use Symfony\Component\Cache\Simple\FilesystemCache;
use Symfony\Component\Cache\Tests\Fixtures\PrunableCache;
/**
* @group time-sensitive
@ -65,7 +65,7 @@ class ChainCacheTest extends CacheTestCase
private function getPruneableMock(): CacheInterface
{
$pruneable = $this->createMock([CacheInterface::class, PruneableInterface::class]);
$pruneable = $this->createMock(PrunableCache::class);
$pruneable
->expects($this->atLeastOnce())
@ -77,7 +77,7 @@ class ChainCacheTest extends CacheTestCase
private function getFailingPruneableMock(): CacheInterface
{
$pruneable = $this->createMock([CacheInterface::class, PruneableInterface::class]);
$pruneable = $this->createMock(PrunableCache::class);
$pruneable
->expects($this->atLeastOnce())