File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function __toString():string {
3333 public function __get (string $ name ):mixed {
3434 switch ($ name ) {
3535 case "size " :
36- return $ this ->size ;
36+ return strlen ( $ this ->content ) ;
3737
3838 case "type " :
3939 return $ this ->type ;
Original file line number Diff line number Diff line change 22namespace Gt \Http \Test ;
33
44use Gt \Http \ArrayBuffer ;
5+ use Gt \Http \Blob ;
56use Gt \Http \FormData ;
67use Gt \Http \Header \ResponseHeaders ;
78use Gt \Http \Request ;
@@ -164,6 +165,23 @@ public function testAwaitJson():void {
164165 self ::assertSame ("phpgt " , $ actualJson ->getString ("name " ));
165166 }
166167
168+ public function testBlob ():void {
169+ $ blobString = random_bytes (32 );
170+
171+ $ stream = new Stream ();
172+ $ stream ->write ($ blobString );
173+
174+ $ sut = (new Response ())->withBody ($ stream );
175+
176+ $ actualBlob = null ;
177+ $ sut ->blob ()->then (function ($ blob ) use (&$ actualBlob ) {
178+ $ actualBlob = $ blob ;
179+ });
180+
181+ self ::assertInstanceOf (Blob::class, $ actualBlob );
182+ self ::assertSame (32 , $ actualBlob ->size );
183+ }
184+
167185 public function testAwaitBlob ():void {
168186 $ blobString = random_bytes (32 );
169187
You can’t perform that action at this time.
0 commit comments