echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
$zip->addEmptyDir('emptydir');
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "emptydir/"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed\n";
+ echo "failed3\n";
}
@unlink($file);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 emptydir/
+OK
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "test.php"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
@unlink($file);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 test.php
+OK
echo "failed1\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "baz/foo.txt",
+ "baz/bar.baz"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed2\n";
+ echo "failed3\n";
}
?>
--CLEAN--
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/foo.txt
-5 baz/bar.baz
+OK
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "baz/foo.txt",
+ "baz/bar.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed\n";
+ echo "failed3\n";
}
?>
--CLEAN--
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/bar.txt
-5 baz/foo.txt
+OK
if (!$zip->status == ZIPARCHIVE::ER_OK) {
var_dump($zip);
- echo "failed\n";
+ echo "failed2\n";
}
$zip->close();
if (!$zip->open($file)) {
- exit('failed');
+ exit('failed3');
}
-dump_entries_name($zip);
-echo "\n";
+if (!verify_entries($zip, [
+ "entry1.txt",
+ "entry2.txt",
+ "dir/entry2.txt"
+])) {
+ exit("failed4");
+} else {
+ echo "OK\n";
+}
if (!$zip->renameIndex(0, 'ren_entry1.txt')) {
echo "failed index 0\n";
if (!$zip->renameName('dir/entry2.txt', 'dir3/ren_entry2.txt')) {
echo "failed name dir/entry2.txt\n";
}
-dump_entries_name($zip);
+
+if (!verify_entries($zip, [
+ "ren_entry1.txt",
+ "entry2.txt",
+ "dir3/ren_entry2.txt"
+])) {
+ exit("failed5");
+} else {
+ echo "OK\n";
+}
$zip->close();
@unlink($file);
?>
--EXPECT--
-0 entry1.txt
-1 entry2.txt
-2 dir/entry2.txt
-
-0 ren_entry1.txt
-1 entry2.txt
-2 dir3/ren_entry2.txt
+OK
+OK
<?php
+function verify_entries($zip, $entries = []) {
+ $verified = true;
+ $found = [];
-function dump_entries_name($z) {
- for($i=0; $i<$z->numFiles; $i++) {
- $sb = $z->statIndex($i);
- echo $i . ' ' . $sb['name'] . "\n";
- }
+ for ($index = 0; $index < $zip->numFiles; $index++) {
+ $stat = $zip->statIndex($index);
+
+ if (!in_array($stat["name"], $entries)) {
+ $verified = false;
+ }
+
+ $found[] = $stat["name"];
+ }
+
+ if (!$verified) {
+ var_dump($found);
+ }
+
+ return $verified;
}
+
/* recursively remove a directoryy */
function rmdir_rf($dir) {
if ($handle = opendir($dir)) {