From b2c1cee51a5af1712ab14b61db1e505bf377df2b Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Thu, 26 Mar 2026 22:07:24 +0100 Subject: [PATCH] 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) --- tests/Service/MeilisearchServiceTest.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/Service/MeilisearchServiceTest.php b/tests/Service/MeilisearchServiceTest.php index 4e7f305..c3e0707 100644 --- a/tests/Service/MeilisearchServiceTest.php +++ b/tests/Service/MeilisearchServiceTest.php @@ -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,