From ae4188c0638948e1523df9f5c88383237d13869f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 12:05:48 +0000 Subject: [PATCH] fix: template interpolation and Cache::fake() in tests - interpolateVariables: use string concatenation for triple-brace placeholders instead of PHP string interpolation which only produces single braces - AgentToolRegistryTest: replace Cache::fake() (not available) with Cache::flush() since array driver is already in-memory Co-Authored-By: Claude Opus 4.6 --- Jobs/ProcessContentTask.php | 6 ++++-- tests/Unit/AgentToolRegistryTest.php | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Jobs/ProcessContentTask.php b/Jobs/ProcessContentTask.php index ddb4b17..840dce4 100644 --- a/Jobs/ProcessContentTask.php +++ b/Jobs/ProcessContentTask.php @@ -111,10 +111,12 @@ class ProcessContentTask implements ShouldQueue private function interpolateVariables(string $template, array $data): string { foreach ($data as $key => $value) { + $placeholder = '{{{' . $key . '}}}'; + if (is_string($value)) { - $template = str_replace("{{{$key}}}", $value, $template); + $template = str_replace($placeholder, $value, $template); } elseif (is_array($value)) { - $template = str_replace("{{{$key}}}", json_encode($value), $template); + $template = str_replace($placeholder, json_encode($value), $template); } } diff --git a/tests/Unit/AgentToolRegistryTest.php b/tests/Unit/AgentToolRegistryTest.php index 29f3636..668f563 100644 --- a/tests/Unit/AgentToolRegistryTest.php +++ b/tests/Unit/AgentToolRegistryTest.php @@ -105,7 +105,7 @@ function makeApiKey(int $id, array $scopes = [], ?array $toolScopes = null): Api describe('forApiKey caching', function () { beforeEach(function () { - Cache::fake(); + Cache::flush(); }); it('returns the correct tools on first call (cache miss)', function () { @@ -213,7 +213,7 @@ describe('cache TTL', function () { }); it('stores entries in cache after first call', function () { - Cache::fake(); + Cache::flush(); $registry = new AgentToolRegistry; $registry->register(makeTool('plan.create', [])); @@ -231,7 +231,7 @@ describe('cache TTL', function () { describe('flushCacheForApiKey', function () { beforeEach(function () { - Cache::fake(); + Cache::flush(); }); it('removes the cached entry for the given key id', function () {