Skip to content

Commit 66fd1d1

Browse files
committed
Test encoding stream size
1 parent 20ffbdc commit 66fd1d1

8 files changed

+66
-0
lines changed

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_knows_the_content_size()
44+
{
45+
$stream = new MemoryStream('This is a stream');
46+
$this->beConstructedWith($stream, 6);
47+
48+
$this->getSize()->shouldReturn(strlen("10\r\nThis is a stream\r\n0\r\n\r\n"));
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_knows_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(strlen(gzcompress('This is a test stream')));
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_knows_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(strlen('testtest'));
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_knows_the_content_size()
46+
{
47+
$stream = new MemoryStream(gzcompress('This is a test stream'));
48+
$this->beConstructedWith($stream);
49+
50+
$this->getSize()->shouldReturn(strlen('This is a test stream'));
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_knows_the_content_size()
41+
{
42+
$stream = new MemoryStream('This stream is a test stream');
43+
$this->beConstructedWith($stream);
44+
45+
$this->getSize()->shouldReturn(strlen(gzdeflate('This stream is a test stream')));
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_knows_the_content_size()
46+
{
47+
$stream = new MemoryStream(gzencode('This is a test stream'));
48+
$this->beConstructedWith($stream);
49+
50+
$this->getSize()->shouldReturn(strlen('This is a test stream'));
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_knows_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(strlen(gzencode('This is a test stream')));
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_knows_the_content_size()
41+
{
42+
$stream = new MemoryStream(gzdeflate('This stream is a test stream'));
43+
$this->beConstructedWith($stream);
44+
45+
$this->getSize()->shouldReturn(strlen('This stream is a test stream'));
46+
}
3947
}

0 commit comments

Comments
 (0)