Skip to content

Commit 3111b5f

Browse files
committed
test: Response::awaitFormData
1 parent 8d9be51 commit 3111b5f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/phpunit/ResponseTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@ public function testFormData():void {
180180
self::assertSame("orange", $actualFormData->getString("colour"));
181181
}
182182

183+
public function testAwaitFormData():void {
184+
$data = [
185+
"name" => "Cody",
186+
"colour" => "orange",
187+
];
188+
189+
$stream = new Stream();
190+
$stream->write(http_build_query($data));
191+
192+
$sut = new Response();
193+
$sut = $sut->withHeader("Content-type", "application/x-www-form-urlencoded");
194+
$sut = $sut->withBody($stream);
195+
196+
$formData = $sut->awaitFormData();
197+
self::assertInstanceOf(FormData::class, $formData);
198+
self::assertSame("Cody", $formData->getString("name"));
199+
self::assertSame("orange", $formData->getString("colour"));
200+
}
201+
183202
public function testRedirect_sendsFileLineDebug():void {
184203
$sut = (new Response());
185204
$sut->redirect("/somewhere");

0 commit comments

Comments
 (0)