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 <noreply@anthropic.com>
This commit is contained in:
parent
b86714db6e
commit
ae4188c063
2 changed files with 7 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue