-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
211c668
commit 32fb237
Showing
6 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/Testing/Responses/Fixtures/Threads/ThreadDeleteResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Threads; | ||
|
||
final class ThreadDeleteResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'id' => 'thread_agvtHUGezjTCt4SKgQg0NJ2Y', | ||
'object' => 'thread.deleted', | ||
'deleted' => true, | ||
]; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Testing/Responses/Fixtures/Threads/ThreadListResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Threads; | ||
|
||
final class ThreadListResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'object' => 'list', | ||
'data' => [ | ||
[ | ||
'id' => 'thread_agvtHUGezjTCt4SKgQg0NJ2Y', | ||
'object' => 'thread', | ||
'created_at' => 1_699_621_778, | ||
'metadata' => [], | ||
], | ||
], | ||
'first_id' => 'thread_agvtHUGezjTCt4SKgQg0NJ2Y', | ||
'last_id' => 'thread_agvtHUGezjTCt4SKgQg0NJ2Y', | ||
'has_more' => false, | ||
]; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Testing/Responses/Fixtures/Threads/ThreadResponseFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace OpenAI\Testing\Responses\Fixtures\Threads; | ||
|
||
final class ThreadResponseFixture | ||
{ | ||
public const ATTRIBUTES = [ | ||
'id' => 'thread_agvtHUGezjTCt4SKgQg0NJ2Y', | ||
'object' => 'thread', | ||
'created_at' => 1_699_621_778, | ||
'metadata' => [], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Meta\MetaInformation; | ||
use OpenAI\Responses\Threads\ThreadDeleteResponse; | ||
|
||
test('from', function () { | ||
$result = ThreadDeleteResponse::from(threadDeleteResource(), meta()); | ||
|
||
expect($result) | ||
->id->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y') | ||
->object->toBe('thread.deleted') | ||
->deleted->toBe(true) | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('as array accessible', function () { | ||
$result = ThreadDeleteResponse::from(threadDeleteResource(), meta()); | ||
|
||
expect($result['id']) | ||
->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y'); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = ThreadDeleteResponse::from(threadDeleteResource(), meta()); | ||
|
||
expect($result->toArray()) | ||
->toBe(threadDeleteResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = ThreadDeleteResponse::fake(); | ||
|
||
expect($response) | ||
->id->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y') | ||
->deleted->toBe(true); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = ThreadDeleteResponse::fake([ | ||
'id' => 'thread_1234', | ||
'deleted' => false, | ||
]); | ||
|
||
expect($response) | ||
->id->toBe('thread_1234') | ||
->deleted->toBe(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Meta\MetaInformation; | ||
use OpenAI\Responses\Threads\ThreadListResponse; | ||
use OpenAI\Responses\Threads\ThreadResponse; | ||
|
||
test('from', function () { | ||
$response = ThreadListResponse::from(threadListResource(), meta()); | ||
|
||
expect($response) | ||
->toBeInstanceOf(ThreadListResponse::class) | ||
->object->toBe('list') | ||
->data->toBeArray()->toHaveCount(2) | ||
->data->each->toBeInstanceOf(ThreadResponse::class) | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('as array accessible', function () { | ||
$response = ThreadListResponse::from(threadListResource(), meta()); | ||
|
||
expect($response['object'])->toBe('list'); | ||
}); | ||
|
||
test('to array', function () { | ||
$response = ThreadListResponse::from(threadListResource(), meta()); | ||
|
||
expect($response->toArray()) | ||
->toBeArray() | ||
->toBe(threadListResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = ThreadListResponse::fake(); | ||
|
||
expect($response['data'][0]) | ||
->id->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y'); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = ThreadListResponse::fake([ | ||
'data' => [ | ||
[ | ||
'id' => 'thread_1234', | ||
], | ||
], | ||
]); | ||
|
||
expect($response['data'][0]) | ||
->id->toBe('thread_1234'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use OpenAI\Responses\Meta\MetaInformation; | ||
use OpenAI\Responses\Threads\ThreadResponse; | ||
|
||
test('from', function () { | ||
$result = ThreadResponse::from(threadResource(), meta()); | ||
|
||
expect($result) | ||
->id->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y') | ||
->object->toBe('thread') | ||
->createdAt->toBe(1699621778) | ||
->metadata->toBe([]) | ||
->meta()->toBeInstanceOf(MetaInformation::class); | ||
}); | ||
|
||
test('as array accessible', function () { | ||
$result = ThreadResponse::from(threadResource(), meta()); | ||
|
||
expect($result['id']) | ||
->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y'); | ||
}); | ||
|
||
test('to array', function () { | ||
$result = ThreadResponse::from(threadResource(), meta()); | ||
|
||
expect($result->toArray()) | ||
->toBe(threadResource()); | ||
}); | ||
|
||
test('fake', function () { | ||
$response = ThreadResponse::fake(); | ||
|
||
expect($response) | ||
->id->toBe('thread_agvtHUGezjTCt4SKgQg0NJ2Y'); | ||
}); | ||
|
||
test('fake with override', function () { | ||
$response = ThreadResponse::fake([ | ||
'id' => 'thread_1234', | ||
]); | ||
|
||
expect($response) | ||
->id->toBe('thread_1234'); | ||
}); |