fix: template interpolation and Cache::fake() in tests
Some checks failed
CI / PHP 8.4 (push) Failing after 1m26s
CI / PHP 8.3 (push) Failing after 1m55s

- 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 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-23 12:05:48 +00:00
parent b86714db6e
commit ae4188c063
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 7 additions and 5 deletions

View file

@ -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);
}
}

View file

@ -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 () {