1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/zlib/tests/zlib_wrapper_level.phpt
Gina Peter Banyard 5bd18e3fdc ext/zlib: Refactor tests (#18887)
- Use INI sections
- Use CGI sections
- Move data into a subfolder
- Remove ZPP tests
- Fix various bugs within tests
- Simplify some


Found while working on #18879
2025-06-21 18:03:50 +01:00

42 lines
872 B
PHP

--TEST--
compress.zlib:// wrapper with compression level
--EXTENSIONS--
zlib
--SKIPIF--
<?php
in_array('compress.zlib', stream_get_wrappers()) || die('skip No zlib wrapper');
?>
--FILE--
<?php declare(strict_types=1);
$filename = tempnam(sys_get_temp_dir(), "php-zlib-test-");
$thisfile = file_get_contents(__FILE__);
function write_at_level(int $level) {
global $filename, $thisfile;
$ctx = stream_context_create(['zlib' => ['level' => $level] ]);
$fp = fopen("compress.zlib://$filename", 'w', false, $ctx);
for ($i = 0; $i < 10; ++$i) {
fwrite($fp, $thisfile);
}
fclose($fp);
$size = filesize($filename);
unlink($filename);
return $size;
}
$size1 = write_at_level(1);
$size9 = write_at_level(9);
var_dump(10 * strlen($thisfile));
var_dump($size1);
var_dump($size9);
var_dump($size9 < $size1);
?>
--EXPECTF--
int(%d)
int(%d)
int(%d)
bool(true)