]> granicus.if.org Git - php/commitdiff
- sync tests with pecl
authorPierre Joye <pajoye@php.net>
Tue, 4 Nov 2008 13:24:39 +0000 (13:24 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 4 Nov 2008 13:24:39 +0000 (13:24 +0000)
ext/zip/tests/bug38943.inc [new file with mode: 0644]
ext/zip/tests/bug38943_2.phpt [new file with mode: 0644]
ext/zip/tests/pecl12414.phpt [new file with mode: 0644]
ext/zip/tests/pecl12414.zip [new file with mode: 0644]

diff --git a/ext/zip/tests/bug38943.inc b/ext/zip/tests/bug38943.inc
new file mode 100644 (file)
index 0000000..a6f45e8
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+class myZip extends ZipArchive {
+       private $test = 0;
+       public $testp = 1;
+       private $testarray = array();
+
+       public function __construct() {
+               $this->testarray[] = 1;
+               var_dump($this->testarray);
+       }
+}
+
+$z = new myZip;
+$z->testp = "foobar";
+var_dump($z);
+
diff --git a/ext/zip/tests/bug38943_2.phpt b/ext/zip/tests/bug38943_2.phpt
new file mode 100644 (file)
index 0000000..1aaba37
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+#38943, properties in extended class cannot be set (5.3)
+--SKIPIF--
+<?php
+/* $Id$ */
+if(!extension_loaded('zip')) die('skip');
+if (!defined('PHP_VERSION_MAJOR')) die('skip test for5.3+ only');
+?>
+--FILE--
+<?php
+include 'bug38943.inc';
+?>
+--EXPECTF--
+array(1) {
+  [0]=>
+  int(1)
+}
+object(myZip)#1 (%d) {
+  ["test":"myZip":private]=>
+  int(0)
+  ["testp"]=>
+  string(6) "foobar"
+  ["testarray":"myZip":private]=>
+  array(1) {
+    [0]=>
+    int(1)
+  }
+  ["status"]=>
+  int(0)
+  ["statusSys"]=>
+  int(0)
+  ["numFiles"]=>
+  int(0)
+  ["filename"]=>
+  string(0) ""
+  ["comment"]=>
+  string(0) ""
+}
diff --git a/ext/zip/tests/pecl12414.phpt b/ext/zip/tests/pecl12414.phpt
new file mode 100644 (file)
index 0000000..ab11d21
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #12414 ( extracting files from damaged archives)
+--SKIPIF--
+<?php
+/*$ */
+if(!extension_loaded('zip')) die('skip');
+ ?>
+--FILE--
+<?php
+$filename = 'MYLOGOV2.GFX';
+$zipname = dirname(__FILE__) . "/pecl12414.zip";
+$za = new ZipArchive();
+$res =$za->open($zipname);
+if ($res === TRUE) {
+       $finfo=$za->statName($filename);
+       $file_size=$finfo['size'];
+
+       if($file_size>0) {
+               $contents=$za->getFromName($filename);
+
+               echo "ZIP contents size: " . strlen($contents) . "\n";
+               if(strlen($contents)!=$file_size) {
+                       echo "zip_readfile recorded data does not match unpacked size: " . $zipname . " : " . $filename;
+               }
+       } else {
+               $contents=false;
+               echo "zip_readfile could not open stream from zero length file " . $zipname . " : " .$filename;
+       }
+
+       $za->close();
+} else {
+       echo "zip_readfile could not read from " . $zipname . " : " . $filename;
+}
+
+?>
+--DONE--
+--EXPECTF--
+ZIP contents size: %d
+zip_readfile recorded data does not match unpacked size: %specl12414.zip : MYLOGOV2.GFX
diff --git a/ext/zip/tests/pecl12414.zip b/ext/zip/tests/pecl12414.zip
new file mode 100644 (file)
index 0000000..6cbc60f
Binary files /dev/null and b/ext/zip/tests/pecl12414.zip differ