mirror of
https://github.com/php-win-ext/php-rar.git
synced 2026-04-27 14:23:14 +02:00
78b7a5f63b
Add a musl/LLVM Docker build environment for compiling portable Linux binaries that work on both musl and glibc systems, along with a minimal PHP Docker image for testing. Add CI workflows to build and publish these images to ghcr.io. Update test and build scripts to use the new Docker-based environment, and remove SKIPIF guards from tests since the extension is always present and doing otherwise would mask extension loading failures.
80 lines
1.9 KiB
PHP
80 lines
1.9 KiB
PHP
--TEST--
|
|
RarArchive::setAllowBroken has the desired effect
|
|
--FILE--
|
|
<?php
|
|
|
|
require __DIR__ . "/php8compat.php.inc";
|
|
function retnull() { return null; }
|
|
$b = dirname(__FILE__) . "/multi_broken.part1.rar";
|
|
|
|
echo "* broken file; bad arguments\n";
|
|
$a = RarArchive::open($b, null, 'retnull');
|
|
argerr(function() use ($a) {
|
|
$a->setAllowBroken();
|
|
});
|
|
argerr(function() use ($a) {
|
|
rar_allow_broken_set($a);
|
|
});
|
|
|
|
echo "\n* broken file; do not allow broken (default)\n";
|
|
$a = RarArchive::open($b, null, 'retnull');
|
|
var_dump($a->getEntries());
|
|
var_dump(count($a));
|
|
|
|
echo "\n* broken file; do not allow broken (explicit)\n";
|
|
$a = RarArchive::open($b, null, 'retnull');
|
|
$a->setAllowBroken(false);
|
|
var_dump($a->getEntries());
|
|
var_dump(count($a));
|
|
|
|
echo "\n* broken file; allow broken\n";
|
|
$a = RarArchive::open($b, null, 'retnull');
|
|
$a->setAllowBroken(true);
|
|
foreach ($a->getEntries() as $e) {
|
|
echo "$e\n";
|
|
}
|
|
var_dump(count($a));
|
|
|
|
echo "\n* broken file; allow broken; non OOP\n";
|
|
$a = RarArchive::open($b, null, 'retnull');
|
|
rar_allow_broken_set($a, true);
|
|
foreach ($a->getEntries() as $e) {
|
|
echo "$e\n";
|
|
}
|
|
var_dump(count($a));
|
|
|
|
echo "\n";
|
|
echo "Done.\n";
|
|
--EXPECTF--
|
|
* broken file; bad arguments
|
|
|
|
Warning: RarArchive::setAllowBroken() expects exactly 1 parameter, 0 given in %s on line %d
|
|
|
|
Warning: rar_allow_broken_set() expects exactly 2 parameters, 1 given in %s on line %d
|
|
|
|
* broken file; do not allow broken (default)
|
|
|
|
Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d
|
|
bool(false)
|
|
|
|
Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d
|
|
int(0)
|
|
|
|
* broken file; do not allow broken (explicit)
|
|
|
|
Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d
|
|
bool(false)
|
|
|
|
Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d
|
|
int(0)
|
|
|
|
* broken file; allow broken
|
|
RarEntry for file "file1.txt" (52b28202)
|
|
int(1)
|
|
|
|
* broken file; allow broken; non OOP
|
|
RarEntry for file "file1.txt" (52b28202)
|
|
int(1)
|
|
|
|
Done.
|