8000 test(OpenAI): augment testing for fake() on Responses API (#593) · openai-php/client@69037e9 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 69037e9

Browse files
authored
test(OpenAI): augment testing for fake() on Responses API (#593)
1 parent 4f95624 commit 69037e9

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

src/Testing/Responses/Concerns/Fakeable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ private static function buildAttributes(array $original, array $override): array
2929
$new = [];
3030

3131
foreach ($original as $key => $entry) {
32-
$new[$key] = is_array($entry) ?
33-
self::buildAttributes($entry, $override[$key] ?? []) :
34-
$override[$key] ?? $entry;
32+
$new[$key] = is_array($entry)
33+
? self::buildAttributes($entry, $override[$key] ?? [])
34+
: $override[$key] ?? $entry;
3535
unset($override[$key]);
3636
}
3737

tests/Fixtures/Responses.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function createResponseResource(): array
1717
'metadata' => [],
1818
'model' => 'gpt-4o-2024-08-06',
1919
'output' => [
20-
outputMessage(),
20+
outputAnnotationMessage(),
2121
outputWebSearchToolCall(),
2222
outputFileSearchToolCall(),
2323
outputComputerToolCall(),
@@ -77,7 +77,7 @@ function retrieveResponseResource(): array
7777
'model' => 'gpt-4o-2024-08-06',
7878
'output' => [
7979
outputWebSearchToolCall(),
80-
outputMessage(),
80+
outputAnnotationMessage(),
8181
],
8282
'parallel_tool_calls' => true,
8383
'previous_response_id' => null,
@@ -249,7 +249,27 @@ function outputReasoning(): array
249249
/**
250250
* @return array<string, mixed>
251251
*/
252-
function outputMessage(): array
252+
function outputBasicMessage(): array
253+
{
254+
return [
255+
'content' => [
256+
[
257+
'annotations' => [],
258+
'text' => 'This is a basic message.',
259+
'type' => 'output_text',
260+
],
261+
],
262+
'id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
263+
'role' => 'assistant',
264+
'status' => 'completed',
265+
'type' => 'message',
266+
];
267+
}
268+
269+
/**
270+
* @return array<string, mixed>
271+
*/
272+
function outputAnnotationMessage(): array
253273
{
254274
return [
255275
'content' => [

tests/Responses/Responses/CreateResponse.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@
8181
'id' => 'resp_1234',
8282
'object' => 'custom_response',
8383
'status' => 'failed',
84+
'output' => [
85+
outputBasicMessage(),
86+
],
8487
]);
8588

8689
expect($response)
8790
->id->toBe('resp_1234')
8891
->object->toBe('custom_response')
89-
->status->toBe('failed');
92+
->status->toBe('failed')
93+
->output->toBeArray();
94+
95+
expect($response->output[0]['content'][0])
96+
->type->toBe('output_text')
97+
->text->toBe('This is a basic message.');
9098
});

0 commit comments

Comments
 (0)
0