-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathFilteredStreamStubSpec.php
69 lines (56 loc) · 1.95 KB
/
FilteredStreamStubSpec.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace spec\Http\Message\Encoding;
use Http\Message\Encoding\FilteredStream;
use PhpSpec\ObjectBehavior;
use Psr\Http\Message\StreamInterface;
class FilteredStreamStubSpec extends ObjectBehavior
{
function it_throws_during_instantiation_with_invalid_read_filter_options(StreamInterface $stream)
{
$this->beAnInstanceOf('spec\Http\Message\Encoding\FilteredStreamStub');
$this->beConstructedWith($stream, 'foo');
$this->shouldThrow('RuntimeException')->duringInstantiation();
}
function it_throws_during_instantiation_with_invalid_write_filter_options(StreamInterface $stream)
{
$this->beAnInstanceOf('spec\Http\Message\Encoding\FilteredStreamStub');
$this->beConstructedWith($stream, null, 'foo');
$this->shouldThrow('RuntimeException')->duringInstantiation();
}
function let(StreamInterface $stream)
{
$this->beAnInstanceOf('spec\Http\Message\Encoding\FilteredStreamStub');
$this->beConstructedWith($stream);
}
function it_reads()
{
// "This is a test stream" | base64_encode
$stream = new MemoryStream('This is a test stream');
$this->beConstructedWith($stream);
$this->read(4)->shouldReturn('VGhp');
}
function it_gets_content()
{
// "This is a test stream" | base64_encode
$stream = new MemoryStream('This is a test stream');
$this->beConstructedWith($stream);
$this->getContents()->shouldReturn('VGhpcyBpcyBhIHRlc3Qgc3RyZWFt');
}
function it_does_not_know_the_content_size()
{
$stream = new MemoryStream(gzencode('This is a test stream'));
$this->beConstructedWith($stream);
$this->getSize()->shouldBeNull();
}
}
class FilteredStreamStub extends FilteredStream
{
protected function readFilter()
{
return 'convert.base64-encode';
}
protected function writeFilter()
{
return 'convert.base64-encode';
}
}