Skip to content

Commit 71e1e0f

Browse files
committed
Fix FilteredStream::getSize returned value
1 parent 1761cb6 commit 71e1e0f

10 files changed

+78
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## Fixed
6+
7+
- FilteredStream::getSize returns null because the contents size is unknown.
8+
59
### Deprecated
610

711
- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code.

spec/Encoding/ChunkStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ function it_chunks_in_multiple()
3939

4040
$this->getContents()->shouldReturn("6\r\nThis i\r\n6\r\ns a st\r\n4\r\nream\r\n0\r\n\r\n");
4141
}
42+
43+
function it_does_not_know_the_content_size()
44+
{
45+
$stream = new MemoryStream('This is a stream');
46+
$this->beConstructedWith($stream, 6);
47+
48+
$this->getSize()->shouldReturn(null);
49+
}
4250
}

spec/Encoding/CompressStreamSpec.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ function it_gets_content()
4141
$stream->rewind();
4242
$this->getContents()->shouldReturn(gzcompress('This is a test stream'));
4343
}
44+
45+
function it_does_not_know_the_content_size()
46+
{
47+
$stream = new MemoryStream('This is a test stream');
48+
$this->beConstructedWith($stream);
49+
50+
$stream->rewind();
51+
$this->getSize()->shouldReturn(null);
52+
}
4453
}

spec/Encoding/DechunkStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ function it_gets_content()
4040

4141
$this->getContents()->shouldReturn('test');
4242
}
43+
44+
function it_does_not_know_the_content_size()
45+
{
46+
$stream = new MemoryStream("4\r\ntest\r\n4\r\ntest\r\n0\r\n\r\n\0");
47+
$this->beConstructedWith($stream);
48+
49+
$this->getSize()->shouldReturn(null);
50+
}
4351
}

spec/Encoding/DecompressStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ function it_gets_content()
4141

4242
$this->getContents()->shouldReturn('This is a test stream');
4343
}
44+
45+
function it_does_not_know_the_content_size()
46+
{
47+
$stream = new MemoryStream(gzcompress('This is a test stream'));
48+
$this->beConstructedWith($stream);
49+
50+
$this->getSize()->shouldReturn(null);
51+
}
4452
}

spec/Encoding/DeflateStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ function it_gets_content()
3636
$stream->rewind();
3737
$this->getContents()->shouldReturn(gzdeflate('This is a test stream'));
3838
}
39+
40+
function it_does_not_know_the_content_size()
41+
{
42+
$stream = new MemoryStream('This stream is a test stream');
43+
$this->beConstructedWith($stream);
44+
45+
$this->getSize()->shouldReturn(null);
46+
}
3947
}

spec/Encoding/GzipDecodeStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ function it_gets_content()
4141

4242
$this->getContents()->shouldReturn('This is a test stream');
4343
}
44+
45+
function it_does_not_know_the_content_size()
46+
{
47+
$stream = new MemoryStream(gzencode('This is a test stream'));
48+
$this->beConstructedWith($stream);
49+
50+
$this->getSize()->shouldReturn(null);
51+
}
4452
}

spec/Encoding/GzipEncodeStreamSpec.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ function it_gets_content()
4141
$stream->rewind();
4242
$this->getContents()->shouldReturn(gzencode('This is a test stream'));
4343
}
44+
45+
function it_does_not_know_the_content_size()
46+
{
47+
$stream = new MemoryStream('This is a test stream');
48+
$this->beConstructedWith($stream);
49+
50+
$stream->rewind();
51+
$this->getSize()->shouldReturn(null);
52+
}
4453
}

spec/Encoding/InflateStreamSpec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ function it_gets_content()
3636

3737
$this->getContents()->shouldReturn('This is a test stream');
3838
}
39+
40+
function it_does_not_know_the_content_size()
41+
{
42+
$stream = new MemoryStream(gzdeflate('This stream is a test stream'));
43+
$this->beConstructedWith($stream);
44+
45+
$this->getSize()->shouldReturn(null);
46+
}
3947
}

src/Encoding/FilteredStream.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ public function getContents()
138138
return $buffer;
139139
}
140140

141+
/**
142+
* {@inheritdoc}
143+
*/
144+
public function getSize()
145+
{
146+
return;
147+
}
148+
141149
/**
142150
* {@inheritdoc}
143151
*/

0 commit comments

Comments
 (0)