Skip to content

Commit 672b8d9

Browse files
committed
Add tests
1 parent 85ffb86 commit 672b8d9

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed

tests/Fixtures/Responses.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,50 @@ function outputFileSearchToolCall(): array
191191
];
192192
}
193193

194+
/**
195+
* @return array<string, mixed>
196+
*/
197+
function outputMcpApprovalRequest(): array
198+
{
199+
return [
200+
'id' => 'fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
201+
'server_label' => 'server-name',
202+
'type' => 'mcp_approval_request',
203+
'arguments' => '',
204+
'name' => 'Name',
205+
];
206+
}
207+
208+
/**
209+
* @return array<string, mixed>
210+
*/
211+
function outputMcpCall(): array
212+
{
213+
return [
214+
'id' => 'fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
215+
'server_label' => 'server-name',
216+
'type' => 'mcp_call',
217+
'arguments' => '',
218+
'name' => 'Name',
219+
'approval_request_id' => null,
220+
'error' => null,
221+
'output' => null,
222+
];
223+
}
224+
225+
/**
226+
* @return array<string, mixed>
227+
*/
228+
function outputMcpListTools(): array
229+
{
230+
return [
231+
'id' => 'fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c',
232+
'server_label' => 'server-name',
233+
'type' => 'mcp_list_tools',
234+
'tools' => [],
235+
];
236+
}
237+
194238
/**
195239
* @return array<string, mixed>
196240
*/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use OpenAI\Responses\Responses\Output\OutputMcpApprovalRequest;
4+
5+
test('from', function () {
6+
$response = OutputMcpApprovalRequest::from(outputMcpApprovalRequest());
7+
8+
expect($response)
9+
->toBeInstanceOf(OutputMcpApprovalRequest::class)
10+
->id->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c')
11+
->serverLabel->toBe('server-name')
12+
->name->toBe('Name')
13+
->arguments->toBe('');
14+
});
15+
16+
test('as array accessible', function () {
17+
$response = OutputMcpApprovalRequest::from(outputMcpApprovalRequest());
18+
19+
expect($response['id'])->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c');
20+
});
21+
22+
test('to array', function () {
23+
$response = OutputMcpApprovalRequest::from(outputMcpApprovalRequest());
24+
25+
expect($response->toArray())
26+
->toBeArray()
27+
->toBe(outputMcpApprovalRequest());
28+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use OpenAI\Responses\Responses\Output\OutputMcpCall;
4+
5+
test('from', function () {
6+
$response = OutputMcpCall::from(outputMcpCall());
7+
8+
expect($response)
9+
->toBeInstanceOf(OutputMcpCall::class)
10+
->id->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c')
11+
->serverLabel->toBe('server-name')
12+
->name->toBe('Name')
13+
->arguments->toBe('')
14+
->type->toBe('mcp_call')
15+
->approvalRequestId->toBeNull()
16+
->error->toBeNull()
17+
->output->toBeNull();
18+
});
19+
20+
test('as array accessible', function () {
21+
$response = OutputMcpCall::from(outputMcpCall());
22+
23+
expect($response['id'])->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c');
24+
});
25+
26+
test('to array', function () {
27+
$response = OutputMcpCall::from(outputMcpCall());
28+
29+
expect($response->toArray())
30+
->toBeArray()
31+
->toBe(outputMcpCall());
32+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use OpenAI\Responses\Responses\Output\OutputMcpListTools;
4+
5+
test('from', function () {
6+
$response = OutputMcpListTools::from(outputMcpListTools());
7+
8+
expect($response)
9+
->toBeInstanceOf(OutputMcpListTools::class)
10+
->id->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c')
11+
->serverLabel->toBe('server-name')
12+
->type->toBe('mcp_list_tools')
13+
->tools->toBeArray();
14+
});
15+
16+
test('as array accessible', function () {
17+
$response = OutputMcpListTools::from(outputMcpListTools());
18+
19+
expect($response['id'])->toBe('fs_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c');
20+
});
21+
22+
test('to array', function () {
23+
$response = OutputMcpListTools::from(outputMcpListTools());
24+
25+
expect($response->toArray())
26+
->toBeArray()
27+
->toBe(outputMcpListTools());
28+
});

0 commit comments

Comments
 (0)