fix: resolve 14 test failures across 3 test files
ProcessContentTaskTest: set mock properties directly instead of
shouldReceive('__get') which doesn't reliably intercept property
access on Mockery mocks of non-existent classes.
HasStreamParsing: fix parseJSONStream chunked read bug where the
inner parse loop restarted at position 0 with stale state from
a previous partial parse. Track scan position across chunks.
AgentDetection: fix Postman regex \bPostman\b → \bPostman/ so it
matches PostmanRuntime (no word boundary between n and R).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5fa46104f4
commit
938081f2f5
3 changed files with 15 additions and 6 deletions
|
|
@ -131,7 +131,7 @@ class AgentDetection
|
|||
'/\bwget\b/i',
|
||||
'/\bpython-requests\b/i',
|
||||
'/\bgo-http-client\b/i',
|
||||
'/\bPostman\b/i',
|
||||
'/\bPostman/i',
|
||||
'/\bInsomnia\b/i',
|
||||
'/\baxios\b/i',
|
||||
'/\bnode-fetch\b/i',
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ trait HasStreamParsing
|
|||
$inString = false;
|
||||
$escape = false;
|
||||
$objectStart = -1;
|
||||
$scanPos = 0;
|
||||
|
||||
while (! $stream->eof()) {
|
||||
$chunk = $stream->read(8192);
|
||||
|
|
@ -129,9 +130,10 @@ trait HasStreamParsing
|
|||
|
||||
$buffer .= $chunk;
|
||||
|
||||
// Parse JSON objects from the buffer
|
||||
// Parse JSON objects from the buffer, continuing from where
|
||||
// the previous iteration left off to preserve parser state.
|
||||
$length = strlen($buffer);
|
||||
$i = 0;
|
||||
$i = $scanPos;
|
||||
|
||||
while ($i < $length) {
|
||||
$char = $buffer[$i];
|
||||
|
|
@ -176,6 +178,7 @@ trait HasStreamParsing
|
|||
$buffer = substr($buffer, $i + 1);
|
||||
$length = strlen($buffer);
|
||||
$i = -1; // Will be incremented to 0
|
||||
$scanPos = 0;
|
||||
$objectStart = -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -183,6 +186,9 @@ trait HasStreamParsing
|
|||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Save scan position so we resume from here on the next chunk
|
||||
$scanPos = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,12 @@ function makeTask(array $attributes = []): ContentTask
|
|||
$task->shouldReceive('markCompleted')->byDefault();
|
||||
$task->shouldReceive('markFailed')->byDefault();
|
||||
|
||||
$task->shouldReceive('__get')->andReturnUsing(function (string $prop) use ($attributes) {
|
||||
return $attributes[$prop] ?? null;
|
||||
})->byDefault();
|
||||
// Set properties directly on the mock — Mockery handles __get/__set
|
||||
// internally. Using shouldReceive('__get') doesn't reliably intercept
|
||||
// property access on mocks of non-existent classes.
|
||||
foreach ($attributes as $key => $value) {
|
||||
$task->{$key} = $value;
|
||||
}
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue