Skip to content

Commit dcd9ae0

Browse files
committed
Add test
1 parent 92f922d commit dcd9ae0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/platform/tests/Bridge/Gemini/Gemini/ResultConverterTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\AI\Platform\Bridge\Gemini\Gemini\ResultConverter;
1616
use Symfony\AI\Platform\Exception\RuntimeException;
1717
use Symfony\AI\Platform\Result\RawHttpResult;
18+
use Symfony\AI\Platform\Result\ToolCall;
19+
use Symfony\AI\Platform\Result\ToolCallResult;
1820
use Symfony\Contracts\HttpClient\ResponseInterface;
1921

2022
/**
@@ -40,4 +42,38 @@ public function testConvertThrowsExceptionWithDetailedErrorInformation()
4042

4143
$converter->convert(new RawHttpResult($httpResponse));
4244
}
45+
46+
public function testReturnsToolCallEvenIfMultipleContentPartsAreGiven()
47+
{
48+
$converter = new ResultConverter();
49+
$httpResponse = self::createMock(ResponseInterface::class);
50+
$httpResponse->method('getStatusCode')->willReturn(200);
51+
$httpResponse->method('toArray')->willReturn([
52+
'candidates' => [
53+
[
54+
'content' => [
55+
'parts' => [
56+
[
57+
'text' => 'foo',
58+
],
59+
[
60+
'functionCall' => [
61+
'id' => '1234',
62+
'name' => 'some_tool',
63+
'args' => [],
64+
],
65+
],
66+
],
67+
],
68+
],
69+
],
70+
]);
71+
72+
$result = $converter->convert(new RawHttpResult($httpResponse));
73+
$this->assertInstanceOf(ToolCallResult::class, $result);
74+
$this->assertCount(1, $result->getContent());
75+
$toolCall = $result->getContent()[0];
76+
$this->assertInstanceOf(ToolCall::class, $toolCall);
77+
$this->assertEquals('1234', $toolCall->id);
78+
}
4379
}

0 commit comments

Comments
 (0)