25 $this->assertEquals(
'data', (
string) $body);
26 $this->assertEquals(4, $body->getContentLength());
27 $this->assertEquals(
'PHP', $body->getWrapper());
28 $this->assertEquals(
'TEMP', $body->getStreamType());
30 $handle = fopen(__DIR__ .
'/../../../../phpunit.xml.dist',
'r');
32 $this->fail(
'Could not open test file');
35 $this->assertEquals(__DIR__ .
'/../../../../phpunit.xml.dist', $body->getUri());
36 $this->assertTrue($body->isLocal());
37 $this->assertEquals(__DIR__ .
'/../../../../phpunit.xml.dist', $body->getUri());
38 $this->assertEquals(filesize(__DIR__ .
'/../../../../phpunit.xml.dist'), $body->getContentLength());
47 $this->assertEquals(
'PHP', $body->getWrapper());
48 $this->assertEquals(
'TEMP', $body->getStreamType());
50 $this->assertEquals(
'PHP', $body->getWrapper());
51 $this->assertEquals(
'TEMP', $body->getStreamType());
57 $this->assertEquals(
'foo=bar', (
string) $body);
71 $this->assertFalse($body->getContentEncoding(),
'-> getContentEncoding() must initially return FALSE');
72 $size = $body->getContentLength();
74 $this->assertEquals(
'gzip', $body->getContentEncoding(),
'-> getContentEncoding() must return the correct encoding after compressing');
75 $this->assertEquals(gzdeflate(
'testing 123...testing 123'), (
string) $body);
76 $this->assertTrue($body->getContentLength() < $size);
77 $this->assertTrue($body->uncompress());
78 $this->assertEquals(
'testing 123...testing 123', (
string) $body);
79 $this->assertFalse($body->getContentEncoding(),
'-> getContentEncoding() must reset to FALSE');
81 if (in_array(
'bzip2.*', stream_get_filters())) {
82 $this->assertTrue($body->compress(
'bzip2.compress'));
83 $this->assertEquals(
'compress', $body->getContentEncoding(),
'-> compress() must set \'compress\' as the Content-Encoding');
86 $this->assertFalse($body->compress(
'non-existent'),
'-> compress() must return false when a non-existent stream filter is used');
94 $this->assertSame($body, $body->setStreamFilterContentEncoding(
'zlib.deflate'));
95 $this->assertTrue($body->uncompress(
'zlib.inflate'));
96 $this->assertEquals(
'test', (
string) $body);
101 for ($i = 0; $i < 25000; $i++) {
102 $largeString .= chr(rand(33, 126));
105 $this->assertEquals($largeString, (
string) $body);
106 $this->assertTrue($body->compress());
107 $this->assertNotEquals($largeString, (
string) $body);
108 $compressed = (string) $body;
109 $this->assertTrue($body->uncompress());
110 $this->assertEquals($largeString, (
string) $body);
111 $this->assertEquals($compressed, gzdeflate($largeString));
114 $this->assertFalse($body->compress());
117 unlink(__DIR__ .
'/../TestData/compress_test');
124 $this->assertNull($body->getContentType());
128 $this->assertContains(
'text/x-', $body->getContentType());
134 $this->assertEquals(md5(
'testing 123...testing 123'), $body->getContentMd5());
137 "HTTP/1.1 200 OK" .
"\r\n" .
138 "Content-Length: 3" .
"\r\n\r\n" .
143 $this->assertFalse($body->getContentMd5());
150 $this->assertEquals(md5(
'testing 123'), $body->getContentMd5());
151 $this->assertEquals(4, $body->ftell());
152 $this->assertEquals(
'ing 123', $body->read(1000));
158 $this->assertEquals(
'key1=val1&key2=val2', (
string) $body);
165 $body->setRewindFunction(
function ($body) use (&$rewound) {
167 return $body->seek(0);
170 $this->assertTrue($body->rewind());
171 $this->assertTrue($rewound);
180 $body->setRewindFunction(
'foo');