PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.4.2
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.4.2
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / psr7 / tests / InflateStreamTest.php

InflateStreamTest.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.4.2, at vendor/guzzlehttp/psr7/tests/InflateStreamTest.php

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Tests\Psr7;
3
4 use GuzzleHttp\Psr7;
5 use GuzzleHttp\Psr7\InflateStream;
6 use GuzzleHttp\Psr7\NoSeekStream;
7
8 class InflateStreamTest extends BaseTest
9 {
10 public function testInflatesStreams()
11 {
12 $content = gzencode('test');
13 $a = Psr7\stream_for($content);
14 $b = new InflateStream($a);
15 $this->assertEquals('test', (string) $b);
16 }
17
18 public function testInflatesStreamsWithFilename()
19 {
20 $content = $this->getGzipStringWithFilename('test');
21 $a = Psr7\stream_for($content);
22 $b = new InflateStream($a);
23 $this->assertEquals('test', (string) $b);
24 }
25
26 public function testInflatesStreamsPreserveSeekable()
27 {
28 $content = $this->getGzipStringWithFilename('test');
29 $seekable = Psr7\stream_for($content);
30 $nonSeekable = new NoSeekStream(Psr7\stream_for($content));
31
32 $this->assertTrue((new InflateStream($seekable))->isSeekable());
33 $this->assertFalse((new InflateStream($nonSeekable))->isSeekable());
34 }
35
36 private function getGzipStringWithFilename($original_string)
37 {
38 $gzipped = bin2hex(gzencode($original_string));
39
40 $header = substr($gzipped, 0, 20);
41 // set FNAME flag
42 $header[6]=0;
43 $header[7]=8;
44 // make a dummy filename
45 $filename = '64756d6d7900';
46 $rest = substr($gzipped, 20);
47
48 return hex2bin($header . $filename . $rest);
49 }
50 }
51