Skip to content

Commit 88d2fe7

Browse files
committed
:octocat: +Psr7\decompress_content() test
1 parent 28a5239 commit 88d2fe7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Psr7/MessageHelpersTest.php

+25
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,29 @@ public function testMessageToString(MessageInterface $message, string $expected)
134134
);
135135
}
136136

137+
public function decompressDataProvider(){
138+
return [
139+
'compress' => ['gzcompress', 'compress'],
140+
'deflate' => ['gzdeflate', 'deflate'],
141+
'gzip' => ['gzencode', 'gzip'],
142+
'none' => [null, null],
143+
];
144+
}
145+
146+
/**
147+
* @dataProvider decompressDataProvider
148+
*/
149+
public function testDecompressContent($fn, $encoding){
150+
$data = $expected = str_repeat('compressed string ', 100);
151+
$response = (new Response);
152+
153+
if($fn){
154+
$data = $fn($data);
155+
$response = $response->withHeader('Content-Encoding', $encoding);
156+
}
157+
158+
$response = $response->withBody(Psr17\create_stream($data));
159+
160+
$this->assertSame($expected, Psr7\decompress_content($response));
161+
}
137162
}

0 commit comments

Comments
 (0)