Skip to content

Commit caf4413

Browse files
committed
Updated Test files, Fixed Lint errors, all tests pass except test:unit
1 parent 5585119 commit caf4413

17 files changed

+1006
-413
lines changed

src/Testing/Responses/Concerns/Fakeable.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,29 @@ trait Fakeable
2323
* It also handles cases where fixture ATTRIBUTES might be wrapped in an additional array layer,
2424
* automatically unwrapping single-element arrays to maintain consistency.
2525
*
26-
* @param array<string, mixed> $override Optional attributes to override in the fake response
27-
* @param MetaInformation|null $meta Optional meta information for the response
28-
* @throws \RuntimeException If the Responses namespace cannot be found in the class path
26+
* @param array<string, mixed> $override Optional attributes to override in the fake response
27+
* @param MetaInformation|null $meta Optional meta information for the response
2928
* @return static Returns a new instance of the response class with fake data
29+
*
30+
* @throws \RuntimeException If the Responses namespace cannot be found in the class path
3031
*/
3132
public static function fake(array $override = [], ?MetaInformation $meta = null): static
3233
{
3334
$parts = explode('\\', static::class);
3435
$className = end($parts);
35-
36+
3637
// Find the position of 'Responses' in the namespace
3738
$responsesPos = array_search('Responses', $parts);
3839
if ($responsesPos === false) {
3940
throw new \RuntimeException('Unable to determine fixture path: no Responses namespace found');
4041
}
41-
42+
4243
// Get all parts after 'Responses' to preserve nested structure
4344
$subPath = implode('\\', array_slice($parts, $responsesPos + 1, -1));
44-
45+
4546
// Construct the fixture class path
46-
$namespace = 'OpenAI\\Testing\\Responses\\Fixtures\\' . $subPath . '\\';
47-
$class = $namespace . $className . 'Fixture';
47+
$namespace = 'OpenAI\\Testing\\Responses\\Fixtures\\'.$subPath.'\\';
48+
$class = $namespace.$className.'Fixture';
4849

4950
$attributes = $class::ATTRIBUTES;
5051
// If attributes is a nested array with only one element, use that element

src/Testing/Responses/Fixtures/Responses/CreateResponseFixture.php

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,53 @@
55
final class CreateResponseFixture
66
{
77
public const ATTRIBUTES = [
8-
'id' => 'resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b',
8+
'id' => 'resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c',
99
'object' => 'response',
10-
'created_at' => 1741476542,
10+
'created_at' => 1741484430,
1111
'status' => 'completed',
1212
'error' => null,
1313
'incomplete_details' => null,
1414
'instructions' => null,
1515
'max_output_tokens' => null,
1616
'model' => 'gpt-4o-2024-08-06',
1717
'output' => [
18+
[
19+
'type' => 'web_search_call',
20+
'id' => 'ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
21+
'status' => 'completed',
22+
],
1823
[
1924
'type' => 'message',
20-
'id' => 'msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b',
25+
'id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
2126
'status' => 'completed',
2227
'role' => 'assistant',
2328
'content' => [
2429
[
2530
'type' => 'output_text',
26-
'text' => 'In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool that reflected the stars. As she dipped her horn into the water, the pool began to shimmer, revealing a pathway to a magical realm of endless night skies. Filled with wonder, Lumina whispered a wish for all who dream to find their own hidden magic, and as she glanced back, her hoofprints sparkled like stardust.',
27-
'annotations' => [],
31+
'text' => 'As of today, March 9, 2025, one notable positive news story...',
32+
'annotations' => [
33+
[
34+
'type' => 'url_citation',
35+
'start_index' => 442,
36+
'end_index' => 557,
37+
'url' => 'https://.../?utm_source=chatgpt.com',
38+
'title' => '...',
39+
],
40+
[
41+
'type' => 'url_citation',
42+
'start_index' => 962,
43+
'end_index' => 1077,
44+
'url' => 'https://.../?utm_source=chatgpt.com',
45+
'title' => '...',
46+
],
47+
[
48+
'type' => 'url_citation',
49+
'start_index' => 1336,
50+
'end_index' => 1451,
51+
'url' => 'https://.../?utm_source=chatgpt.com',
52+
'title' => '...',
53+
],
54+
],
2855
],
2956
],
3057
],
@@ -33,7 +60,7 @@ final class CreateResponseFixture
3360
'previous_response_id' => null,
3461
'reasoning' => [
3562
'effort' => null,
36-
'summary' => null,
63+
'generate_summary' => null,
3764
],
3865
'store' => true,
3966
'temperature' => 1.0,
@@ -43,22 +70,34 @@ final class CreateResponseFixture
4370
],
4471
],
4572
'tool_choice' => 'auto',
46-
'tools' => [],
73+
'tools' => [
74+
[
75+
'type' => 'web_search_preview',
76+
'domains' => [],
77+
'search_context_size' => 'medium',
78+
'user_location' => [
79+
'type' => 'approximate',
80+
'city' => null,
81+
'country' => 'US',
82+
'region' => null,
83+
'timezone' => null,
84+
],
85+
],
86+
],
4787
'top_p' => 1.0,
4888
'truncation' => 'disabled',
4989
'usage' => [
50-
'input_tokens' => 36,
90+
'input_tokens' => 328,
5191
'input_tokens_details' => [
5292
'cached_tokens' => 0,
5393
],
54-
'output_tokens' => 87,
94+
'output_tokens' => 356,
5595
'output_tokens_details' => [
5696
'reasoning_tokens' => 0,
5797
],
58-
'total_tokens' => 123,
98+
'total_tokens' => 684,
5999
],
60100
'user' => null,
61101
'metadata' => [],
62-
63102
];
64103
}

src/Testing/Responses/Fixtures/Responses/DeleteResponseFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ final class DeleteResponseFixture
66
{
77
public const ATTRIBUTES = [
88
[
9-
'id' => 'resp_6786a1bec27481909a17d673315b29f6',
9+
'id' => 'resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c',
1010
'object' => 'response',
1111
'deleted' => true,
1212
],

src/Testing/Responses/Fixtures/Responses/ListInputItemsFixture.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ final class ListInputItemsFixture
99
'data' => [
1010
[
1111
'type' => 'message',
12-
'id' => 'resp_item_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b',
12+
'id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
1313
'status' => 'completed',
1414
'role' => 'user',
1515
'content' => [
1616
[
1717
'type' => 'text',
18-
'text' => 'Tell me a story about a unicorn',
18+
'text' => 'What was a positive news story from today?',
1919
'annotations' => [],
2020
],
2121
],
2222
],
2323
],
24-
'first_id' => 'resp_item_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b',
25-
'last_id' => 'resp_item_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b',
24+
'first_id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
25+
'last_id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
2626
'has_more' => false,
2727
];
2828
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
namespace OpenAI\Testing\Responses\Fixtures\Responses;
4+
5+
final class ResponseObjectFixture
6+
{
7+
public const ATTRIBUTES = [
8+
'id' => 'resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c',
9+
'object' => 'response',
10+
'created_at' => 1741484430,
11+
'status' => 'completed',
12+
'error' => null,
13+
'incomplete_details' => null,
14+
'instructions' => null,
15+
'max_output_tokens' => null,
16+
'model' => 'gpt-4o-2024-08-06',
17+
'output' => [
18+
[
19+
'type' => 'web_search_call',
20+
'id' => 'ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
21+
'status' => 'completed',
22+
],
23+
[
24+
'type' => 'message',
25+
'id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
26+
'status' => 'completed',
27+
'role' => 'assistant',
28+
'content' => [
29+
[
30+
'type' => 'output_text',
31+
'text' => 'As of today, March 9, 2025, one notable positive news story...',
32+
'annotations' => [
33+
[
34+
'type' => 'url_citation',
35+
'start_index' => 442,
36+
'end_index' => 557,
37+
'url' => 'https://.../?utm_source=chatgpt.com',
38+
'title' => '...',
39+
],
40+
[
41+
'type' => 'url_citation',
42+
'start_index' => 962,
43+
'end_index' => 1077,
44+
'url' => 'https://.../?utm_source=chatgpt.com',
45+
'title' => '...',
46+
],
47+
[
48+
'type' => 'url_citation',
49+
'start_index' => 1336,
50+
'end_index' => 1451,
51+
'url' => 'https://.../?utm_source=chatgpt.com',
52+
'title' => '...',
53+
],
54+
],
55+
],
56+
],
57+
],
58+
],
59+
'parallel_tool_calls' => true,
60+
'previous_response_id' => null,
61+
'reasoning' => [
62+
'effort' => null,
63+
'generate_summary' => null,
64+
],
65+
'store' => true,
66+
'temperature' => 1.0,
67+
'text' => [
68+
'format' => [
69+
'type' => 'text',
70+
],
71+
],
72+
'tool_choice' => 'auto',
73+
'tools' => [
74+
[
75+
'type' => 'web_search_preview',
76+
'domains' => [],
77+
'search_context_size' => 'medium',
78+
'user_location' => [
79+
'type' => 'approximate',
80+
'city' => null,
81+
'country' => 'US',
82+
'region' => null,
83+
'timezone' => null,
84+
],
85+
],
86+
],
87+
'top_p' => 1.0,
88+
'truncation' => 'disabled',
89+
'usage' => [
90+
'input_tokens' => 328,
91+
'input_tokens_details' => [
92+
'cached_tokens' => 0,
93+
],
94+
'output_tokens' => 356,
95+
'output_tokens_details' => [
96+
'reasoning_tokens' => 0,
97+
],
98+
'total_tokens' => 684,
99+
],
100+
'user' => null,
101+
'metadata' => [],
102+
];
103+
}

src/Testing/Responses/Fixtures/Responses/RetrieveResponseFixture.php

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,53 @@
55
final class RetrieveResponseFixture
66
{
77
public const ATTRIBUTES = [
8-
'id' => 'resp_67cb71b351908190a308f3859487620d06981a8637e6bc44',
8+
'id' => 'resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c',
99
'object' => 'response',
10-
'created_at' => 1741386163,
10+
'created_at' => 1741484430,
1111
'status' => 'completed',
1212
'error' => null,
1313
'incomplete_details' => null,
1414
'instructions' => null,
1515
'max_output_tokens' => null,
1616
'model' => 'gpt-4o-2024-08-06',
1717
'output' => [
18+
[
19+
'type' => 'web_search_call',
20+
'id' => 'ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
21+
'status' => 'completed',
22+
],
1823
[
1924
'type' => 'message',
20-
'id' => 'msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44',
25+
'id' => 'msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c',
2126
'status' => 'completed',
2227
'role' => 'assistant',
2328
'content' => [
2429
[
2530
'type' => 'output_text',
26-
'text' => 'Silent circuits hum, \nThoughts emerge in data streams— \nDigital dawn breaks.',
27-
'annotations' => [],
31+
'text' => 'As of today, March 9, 2025, one notable positive news story...',
32+
'annotations' => [
33+
[
34+
'type' => 'url_citation',
35+
'start_index' => 442,
36+
'end_index' => 557,
37+
'url' => 'https://.../?utm_source=chatgpt.com',
38+
'title' => '...',
39+
],
40+
[
41+
'type' => 'url_citation',
42+
'start_index' => 962,
43+
'end_index' => 1077,
44+
'url' => 'https://.../?utm_source=chatgpt.com',
45+
'title' => '...',
46+
],
47+
[
48+
'type' => 'url_citation',
49+
'start_index' => 1336,
50+
'end_index' => 1451,
51+
'url' => 'https://.../?utm_source=chatgpt.com',
52+
'title' => '...',
53+
],
54+
],
2855
],
2956
],
3057
],
@@ -33,7 +60,7 @@ final class RetrieveResponseFixture
3360
'previous_response_id' => null,
3461
'reasoning' => [
3562
'effort' => null,
36-
'summary' => null,
63+
'generate_summary' => null,
3764
],
3865
'store' => true,
3966
'temperature' => 1.0,
@@ -43,19 +70,32 @@ final class RetrieveResponseFixture
4370
],
4471
],
4572
'tool_choice' => 'auto',
46-
'tools' => [],
73+
'tools' => [
74+
[
75+
'type' => 'web_search_preview',
76+
'domains' => [],
77+
'search_context_size' => 'medium',
78+
'user_location' => [
79+
'type' => 'approximate',
80+
'city' => null,
81+
'country' => 'US',
82+
'region' => null,
83+
'timezone' => null,
84+
],
85+
],
86+
],
4787
'top_p' => 1.0,
4888
'truncation' => 'disabled',
4989
'usage' => [
50-
'input_tokens' => 32,
90+
'input_tokens' => 328,
5191
'input_tokens_details' => [
5292
'cached_tokens' => 0,
5393
],
54-
'output_tokens' => 18,
94+
'output_tokens' => 356,
5595
'output_tokens_details' => [
5696
'reasoning_tokens' => 0,
5797
],
58-
'total_tokens' => 50,
98+
'total_tokens' => 684,
5999
],
60100
'user' => null,
61101
'metadata' => [],

0 commit comments

Comments
 (0)