diff --git a/tests/Response/ChoiceResponseTest.php b/tests/Response/ChoiceResponseTest.php new file mode 100644 index 0000000..036bca4 --- /dev/null +++ b/tests/Response/ChoiceResponseTest.php @@ -0,0 +1,43 @@ +getContent()); + self::assertSame('choice1', $response->getContent()[0]->getContent()); + self::assertNull($response->getContent()[1]->getContent()); + self::assertSame('choice3', $response->getContent()[2]->getContent()); + } + + #[Test] + public function choiceResponseWithNoChoices(): void + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Response must have at least one choice.'); + + new ChoiceResponse(); + } +} diff --git a/tests/Response/StreamResponseTest.php b/tests/Response/StreamResponseTest.php new file mode 100644 index 0000000..40153b0 --- /dev/null +++ b/tests/Response/StreamResponseTest.php @@ -0,0 +1,34 @@ +getContent()); + + $content = iterator_to_array($response->getContent()); + + self::assertCount(2, $content); + self::assertSame('data1', $content[0]); + self::assertSame('data2', $content[1]); + } +} diff --git a/tests/Response/StructuredResponseTest.php b/tests/Response/StructuredResponseTest.php new file mode 100644 index 0000000..0f94481 --- /dev/null +++ b/tests/Response/StructuredResponseTest.php @@ -0,0 +1,30 @@ + 'bar', 'baz' => ['qux']]); + self::assertSame($expected, $response->getContent()); + } + + #[Test] + public function getContentWithObject(): void + { + $response = new StructuredResponse($expected = (object) ['foo' => 'bar', 'baz' => ['qux']]); + self::assertSame($expected, $response->getContent()); + } +} diff --git a/tests/Response/TextResponseTest.php b/tests/Response/TextResponseTest.php new file mode 100644 index 0000000..ffacb0e --- /dev/null +++ b/tests/Response/TextResponseTest.php @@ -0,0 +1,23 @@ +getContent()); + } +} diff --git a/tests/Response/TollCallResponseTest.php b/tests/Response/TollCallResponseTest.php new file mode 100644 index 0000000..c8ae929 --- /dev/null +++ b/tests/Response/TollCallResponseTest.php @@ -0,0 +1,36 @@ +expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Response must have at least one tool call.'); + + new ToolCallResponse(); + } + + #[Test] + public function getContent(): void + { + $response = new ToolCallResponse($toolCall = new ToolCall('ID', 'name', ['foo' => 'bar'])); + self::assertSame([$toolCall], $response->getContent()); + } +}