forked from clue/reactphp-zlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompressorTest.php
More file actions
39 lines (31 loc) · 1.1 KB
/
CompressorTest.php
File metadata and controls
39 lines (31 loc) · 1.1 KB
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
<?php
namespace Clue\Tests\React\Zlib;
use Clue\React\Zlib\Compressor;
class CompressorTest extends TestCase
{
public function testCtorThrowsForInvalidEncoding()
{
$this->expectException(PHP_VERSION_ID >= 80000 ? \ValueError::class : \InvalidArgumentException::class);
new Compressor(0);
}
public function testCtorThrowsForInvalidEncodingAndUnsetsUsedErrorHandler()
{
$handler = set_error_handler(function(){});
restore_error_handler();
try {
new Compressor(0);
} catch (\ValueError $e) {
// handle Error to unset Error handler afterwards (PHP >= 8.0)
} catch (\InvalidArgumentException $e) {
// handle Error to unset Error handler afterwards (PHP < 8.0)
}
$checkHandler = set_error_handler(function(){});
restore_error_handler();
$this->assertEquals($handler, $checkHandler);
}
public function testCtorThrowsForInvalidFlushMode()
{
$this->expectException(\InvalidArgumentException::class);
new Compressor(ZLIB_ENCODING_GZIP, -1, -1);
}
}