Skip to content

Commit 8e3f9c7

Browse files
committed
Fixed test
1 parent e20862f commit 8e3f9c7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Schema/Result/CallToolResult.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,15 @@ public static function fromArray(array $data): self
109109
*/
110110
public function jsonSerialize(): array
111111
{
112-
return [
112+
$result = [
113113
'content' => $this->content,
114114
'isError' => $this->isError,
115115
];
116+
117+
if ($this->structuredContent) {
118+
$result['structuredContent'] = $this->structuredContent;
119+
}
120+
121+
return $result;
116122
}
117123
}

tests/Unit/Server/Handler/Request/CallToolHandlerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ public function testHandleReturnsStructuredContentResult(): void
368368

369369
$this->assertInstanceOf(Response::class, $response);
370370
$this->assertSame($structuredResult, $response->result);
371+
$this->assertEquals(['result' => 'Rendered results'], $response->result->jsonSerialize()['structuredContent'] ?? []);
371372
}
372373

373374
public function testHandleReturnsCallToolResult(): void
@@ -396,6 +397,7 @@ public function testHandleReturnsCallToolResult(): void
396397

397398
$this->assertInstanceOf(Response::class, $response);
398399
$this->assertSame($callToolResult, $response->result);
400+
$this->assertArrayNotHasKey('structuredContent', $response->result->jsonSerialize());
399401
}
400402

401403
/**

0 commit comments

Comments
 (0)