docker-php-extension-installer/scripts/tests/brotli

23 lines
587 B
Plaintext
Raw Normal View History

2024-11-06 09:26:43 +00:00
#!/usr/bin/env php
<?php
foreach ([
'brotli_compress',
'brotli_uncompress',
] as $function) {
if (!function_exists($function)) {
fwrite(STDERR, "Missing function: {$function}\n");
exit(1);
}
}
$data = 'This is some data to be compressed';
$compressed = brotli_compress($data, BROTLI_COMPRESS_LEVEL_MAX, BROTLI_TEXT);
$uncompressed = brotli_uncompress($compressed);
if ($uncompressed !== $data) {
fwrite(STDERR, "brotli_compress() -> brotli_uncompress() failure!\n");
exit(1);
}
echo "brotli_compress() -> brotli_uncompress() works\n";
return 0;