Skip to content

Commit ab3505d

Browse files
committed
test: Response::text
1 parent c8210ab commit ab3505d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private function jsonFromResponseText(string $responseText, int $depth = 512, in
337337
public function text():Promise {
338338
$promise = $this->getPromise();
339339
$promise->then(function(string $responseText) {
340-
$this->deferred->resolve($responseText);
340+
return $responseText;
341341
});
342342

343343
return $promise;

test/phpunit/ResponseTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ public function testAwaitBlob():void {
194194
self::assertSame($blobString, $actualBlob->getContent());
195195
}
196196

197+
public function testText():void {
198+
$responseText = uniqid("Test!" );
199+
200+
$stream = new Stream();
201+
$stream->write($responseText);
202+
203+
$sut = (new Response())->withBody($stream);
204+
205+
$actualText = null;
206+
$sut->text()->then(function($text) use(&$actualText){
207+
$actualText = $text;
208+
});
209+
210+
self::assertSame($responseText, $actualText);
211+
}
212+
197213
public function testAwaitText():void {
198214
$responseText = uniqid("Test! ");
199215

0 commit comments

Comments
 (0)