File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,13 @@ public function __construct(
3636
3737 public function getSize ()
3838 {
39- return max ($ this ->stream ->getSize (), $ this ->remoteStream ->getSize ());
39+ $ remoteSize = $ this ->remoteStream ->getSize ();
40+
41+ if (null === $ remoteSize ) {
42+ return null ;
43+ }
44+
45+ return max ($ this ->stream ->getSize (), $ remoteSize );
4046 }
4147
4248 public function rewind ()
Original file line number Diff line number Diff line change @@ -34,13 +34,22 @@ public function tearDownTest()
3434 $ this ->body ->close ();
3535 }
3636
37- public function testUsesRemoteSizeIfPossible ()
37+ public function testUsesRemoteSizeIfAvailable ()
3838 {
3939 $ body = Psr7 \Utils::streamFor ('test ' );
4040 $ caching = new CachingStream ($ body );
4141 self ::assertSame (4 , $ caching ->getSize ());
4242 }
4343
44+ public function testUsesRemoteSizeIfNotAvailable ()
45+ {
46+ $ body = new Psr7 \PumpStream (function () {
47+ return 'a ' ;
48+ });
49+ $ caching = new CachingStream ($ body );
50+ self ::assertNull ($ caching ->getSize ());
51+ }
52+
4453 public function testReadsUntilCachedToByte ()
4554 {
4655 $ this ->body ->seek (5 );
You can’t perform that action at this time.
0 commit comments