Skip to content

Commit ca0f59f

Browse files
wip test
1 parent 0f6f261 commit ca0f59f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Integration/Http/GenericResponseSenderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tests\Tempest\Integration\Http;
66

7+
use JsonSerializable;
78
use Tempest\Http\GenericRequest;
89
use Tempest\Http\GenericResponse;
910
use Tempest\Http\Method;
@@ -127,6 +128,29 @@ public function test_sending_of_array_to_json(): void
127128
$this->assertSame('{"key":"value"}', $output);
128129
}
129130

131+
public function test_sending_of_json_serializable_to_json(): void
132+
{
133+
ob_start();
134+
135+
$response = new GenericResponse(
136+
status: Status::CREATED,
137+
body: new class implements JsonSerializable {
138+
public function jsonSerialize(): mixed
139+
{
140+
return ['key' => 'value'];
141+
}
142+
},
143+
);
144+
145+
$responseSender = $this->container->get(GenericResponseSender::class);
146+
147+
$responseSender->send($response);
148+
149+
$output = ob_get_clean();
150+
151+
$this->assertSame('{"key":"value"}', $output);
152+
}
153+
130154
public function test_view_body(): void
131155
{
132156
ob_start();

0 commit comments

Comments
 (0)