summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/zip/tests/bug64342_1-mb.phpt16
-rw-r--r--ext/zip/tests/bug64342_1.phpt16
-rw-r--r--ext/zip/tests/oo_addemptydir.phpt20
-rw-r--r--ext/zip/tests/oo_addfile.phpt18
-rw-r--r--ext/zip/tests/oo_addglob.phpt22
-rw-r--r--ext/zip/tests/oo_addpattern.phpt22
-rw-r--r--ext/zip/tests/oo_rename.phpt35
-rw-r--r--ext/zip/tests/utils.inc24
8 files changed, 117 insertions, 56 deletions
diff --git a/ext/zip/tests/bug64342_1-mb.phpt b/ext/zip/tests/bug64342_1-mb.phpt
index 611a416253..6b14c7fb5d 100644
--- a/ext/zip/tests/bug64342_1-mb.phpt
+++ b/ext/zip/tests/bug64342_1-mb.phpt
@@ -21,7 +21,16 @@ if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) {
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";
@@ -30,7 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
diff --git a/ext/zip/tests/bug64342_1.phpt b/ext/zip/tests/bug64342_1.phpt
index 84cd5db993..0baf4c832e 100644
--- a/ext/zip/tests/bug64342_1.phpt
+++ b/ext/zip/tests/bug64342_1.phpt
@@ -21,7 +21,16 @@ if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) {
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";
@@ -30,7 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
diff --git a/ext/zip/tests/oo_addemptydir.phpt b/ext/zip/tests/oo_addemptydir.phpt
index e63952935d..efaa354ecf 100644
--- a/ext/zip/tests/oo_addemptydir.phpt
+++ b/ext/zip/tests/oo_addemptydir.phpt
@@ -20,16 +20,22 @@ if (!$zip->open($file)) {
$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
diff --git a/ext/zip/tests/oo_addfile.phpt b/ext/zip/tests/oo_addfile.phpt
index 7592f5b2b4..271642b6dd 100644
--- a/ext/zip/tests/oo_addfile.phpt
+++ b/ext/zip/tests/oo_addfile.phpt
@@ -21,7 +21,17 @@ if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) {
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";
@@ -29,8 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
@unlink($file);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 test.php
+OK
diff --git a/ext/zip/tests/oo_addglob.phpt b/ext/zip/tests/oo_addglob.phpt
index 0699797a5d..b20d4ab07a 100644
--- a/ext/zip/tests/oo_addglob.phpt
+++ b/ext/zip/tests/oo_addglob.phpt
@@ -29,10 +29,21 @@ if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) {
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--
@@ -44,9 +55,4 @@ unlink($dirname . 'bar.baz');
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/foo.txt
-5 baz/bar.baz
+OK
diff --git a/ext/zip/tests/oo_addpattern.phpt b/ext/zip/tests/oo_addpattern.phpt
index a66ecba312..fe1a57368d 100644
--- a/ext/zip/tests/oo_addpattern.phpt
+++ b/ext/zip/tests/oo_addpattern.phpt
@@ -30,10 +30,21 @@ if (!$zip->addPattern('/\.txt$/', $dir, $options)) {
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--
@@ -45,9 +56,4 @@ unlink($dirname . 'bar.txt');
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/bar.txt
-5 baz/foo.txt
+OK
diff --git a/ext/zip/tests/oo_rename.phpt b/ext/zip/tests/oo_rename.phpt
index 1ec661eed2..518fe35706 100644
--- a/ext/zip/tests/oo_rename.phpt
+++ b/ext/zip/tests/oo_rename.phpt
@@ -23,17 +23,24 @@ $zip->addFromString('dir/entry2.txt', 'entry #2');
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";
@@ -42,16 +49,20 @@ if (!$zip->renameIndex(0, 'ren_entry1.txt')) {
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
diff --git a/ext/zip/tests/utils.inc b/ext/zip/tests/utils.inc
index c7cd2a8b0b..f44ab3af32 100644
--- a/ext/zip/tests/utils.inc
+++ b/ext/zip/tests/utils.inc
@@ -1,11 +1,25 @@
<?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)) {