Skip to content

Commit d084c63

Browse files
authored
Merge pull request #414 from openai-php/fix-faking-response-metadata
Fix faking response metadata
2 parents ff83da9 + 6a57c78 commit d084c63

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Testing/Responses/Concerns/Fakeable.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ private static function buildAttributes(array $original, array $override): array
3535
unset($override[$key]);
3636
}
3737

38-
// we are going to append all remaining overrides with numeric keys
38+
// we are going to append all remaining overrides
3939
foreach ($override as $key => $value) {
40-
if (! is_numeric($key)) {
41-
continue;
42-
}
43-
4440
$new[$key] = $value;
4541
}
4642

tests/Responses/Assistants/AssistantResponse.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@
4646
test('fake with override', function () {
4747
$response = AssistantResponse::fake([
4848
'id' => 'asst_1234',
49+
'metadata' => [
50+
'key' => 'value',
51+
],
4952
]);
5053

5154
expect($response)
52-
->id->toBe('asst_1234');
55+
->id->toBe('asst_1234')
56+
->metadata->toBeArray()
57+
->metadata->key->toBe('value');
5358
});

0 commit comments

Comments
 (0)