Fix MeilisearchServiceTest: use ArrayAdapter instead of CacheInterface mock

ArrayAdapter implements both CacheInterface and CacheItemPoolInterface,
matching the intersection type on the constructor parameter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-26 22:07:24 +01:00
parent 25564e4244
commit b2c1cee51a

View File

@@ -5,10 +5,9 @@ namespace App\Tests\Service;
use App\Message\MeilisearchMessage;
use App\Service\MeilisearchService;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
@@ -16,15 +15,14 @@ class MeilisearchServiceTest extends TestCase
{
private HttpClientInterface $httpClient;
private MessageBusInterface $bus;
private CacheInterface $cache;
private ArrayAdapter $cache;
private MeilisearchService $service;
protected function setUp(): void
{
$this->httpClient = $this->createMock(HttpClientInterface::class);
$this->bus = $this->createMock(MessageBusInterface::class);
$this->cache = $this->createMock(CacheInterface::class);
$this->cache->method('get')->willReturnCallback(fn (string $key, callable $callback) => $callback($this->createMock(ItemInterface::class)));
$this->cache = new ArrayAdapter();
$this->service = new MeilisearchService(
$this->httpClient,
$this->bus,