File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 44
55namespace Tests \Tempest \Integration \Http ;
66
7+ use JsonSerializable ;
78use Tempest \Http \GenericRequest ;
89use Tempest \Http \GenericResponse ;
910use 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 ();
You can’t perform that action at this time.
0 commit comments