diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:36:21 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:36:21 -0400 |
| commit | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (patch) | |
| tree | b38e2e5c6974b9a15f103e5cf884cba9fff90ef4 /ext/zip/tests | |
| parent | a88a88d0986a4a32288c102cdbfebd78d7e91d99 (diff) | |
| download | php-d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76.tar.gz | |
Imported Upstream version 5.2.0upstream/5.2.0
Diffstat (limited to 'ext/zip/tests')
30 files changed, 749 insertions, 0 deletions
diff --git a/ext/zip/tests/001.phpt b/ext/zip/tests/001.phpt new file mode 100644 index 000000000..37dccc055 --- /dev/null +++ b/ext/zip/tests/001.phpt @@ -0,0 +1,12 @@ +--TEST-- +Check for zip presence +--SKIPIF-- +<?php if (!extension_loaded("zip")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php +echo "zip extension is available"; +?> +--EXPECT-- +zip extension is available diff --git a/ext/zip/tests/binarynull.zip b/ext/zip/tests/binarynull.zip Binary files differnew file mode 100644 index 000000000..9da004efe --- /dev/null +++ b/ext/zip/tests/binarynull.zip diff --git a/ext/zip/tests/bug38943.phpt b/ext/zip/tests/bug38943.phpt new file mode 100644 index 000000000..486c16950 --- /dev/null +++ b/ext/zip/tests/bug38943.phpt @@ -0,0 +1,50 @@ +--TEST-- +#38943, properties in extended class cannot be set +--SKIPIF-- +<?php +/* $Id: bug38943.phpt,v 1.1.2.2 2006/10/09 16:02:34 bjori Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?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); +?> +--EXPECTF-- +array(1) { + [0]=> + int(1) +} +object(myZip)#1 (%d) { + ["test:private"]=> + int(0) + ["testp"]=> + string(6) "foobar" + ["testarray: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/bug38944.phpt b/ext/zip/tests/bug38944.phpt new file mode 100644 index 000000000..ee12fad2b --- /dev/null +++ b/ext/zip/tests/bug38944.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #38944 (newly created ZipArchive segfaults when accessing comment property) +--SKIPIF-- +<?php if (!extension_loaded("zip")) print "skip"; ?> +--FILE-- +<?php + +$arc_name = dirname(__FILE__)."/bug38944.zip"; +$foo = new ZipArchive; +$foo->open($arc_name, ZIPARCHIVE::CREATE);; + +var_dump($foo->status); +var_dump($foo->statusSys); +var_dump($foo->numFiles); +var_dump($foo->filename); +var_dump($foo->comment); + +var_dump($foo); + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(0) +int(0) +string(0) "" +string(0) "" +object(ZipArchive)#%d (5) { + ["status"]=> + int(0) + ["statusSys"]=> + int(0) + ["numFiles"]=> + int(0) + ["filename"]=> + string(0) "" + ["comment"]=> + string(0) "" +} +Done diff --git a/ext/zip/tests/bug7214.phpt b/ext/zip/tests/bug7214.phpt new file mode 100644 index 000000000..6f728f5aa --- /dev/null +++ b/ext/zip/tests/bug7214.phpt @@ -0,0 +1,23 @@ +--TEST-- +bug #7214, zip_entry_read() binary safe +--SKIPIF-- +<?php +/* $Id: bug7214.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); + ?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/binarynull.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +$entry = zip_read($zip); +$contents = zip_entry_read($entry, zip_entry_filesize($entry)); +if (strlen($contents) == zip_entry_filesize($entry)) { + echo "Ok"; +} else { + echo "failed"; +} + +?> +--EXPECT-- +Ok
\ No newline at end of file diff --git a/ext/zip/tests/bug7658.odt b/ext/zip/tests/bug7658.odt Binary files differnew file mode 100644 index 000000000..527e09fef --- /dev/null +++ b/ext/zip/tests/bug7658.odt diff --git a/ext/zip/tests/bug7658.phpt b/ext/zip/tests/bug7658.phpt new file mode 100644 index 000000000..1c9fb37ee --- /dev/null +++ b/ext/zip/tests/bug7658.phpt @@ -0,0 +1,60 @@ +--TEST-- +bug #7658, modify archive with general bit flag 3 set +--SKIPIF-- +<?php +/* $Id: bug7658.phpt,v 1.1.2.1 2006/10/02 14:31:04 tony2001 Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_bug7658.odt'; +$zip = new ZipArchive(); +copy($dirname . 'bug7658.odt', $file); +if(!$zip->open($file)) { + echo 'failed'; +} + +dump_entries_name($zip); + +$zip->deleteName('content.xml'); +$zip->addFile($dirname . "bug7658.xml","content.xml"); +$zip->close(); +echo "\n"; +$zip->open($file); +dump_entries_name($zip); +@unlink($file); +?> +--EXPECT-- +0 mimetype +1 Configurations2/statusbar/ +2 Configurations2/accelerator/current.xml +3 Configurations2/floater/ +4 Configurations2/popupmenu/ +5 Configurations2/progressbar/ +6 Configurations2/menubar/ +7 Configurations2/toolbar/ +8 Configurations2/images/Bitmaps/ +9 content.xml +10 styles.xml +11 meta.xml +12 Thumbnails/thumbnail.png +13 settings.xml +14 META-INF/manifest.xml + +0 mimetype +1 Configurations2/statusbar/ +2 Configurations2/accelerator/current.xml +3 Configurations2/floater/ +4 Configurations2/popupmenu/ +5 Configurations2/progressbar/ +6 Configurations2/menubar/ +7 Configurations2/toolbar/ +8 Configurations2/images/Bitmaps/ +9 styles.xml +10 meta.xml +11 Thumbnails/thumbnail.png +12 settings.xml +13 META-INF/manifest.xml +14 content.xml diff --git a/ext/zip/tests/bug7658.xml b/ext/zip/tests/bug7658.xml new file mode 100644 index 000000000..98076f198 --- /dev/null +++ b/ext/zip/tests/bug7658.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0"><office:scripts/><office:font-face-decls><style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/><style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-pitch="variable"/><style:font-face style:name="Estrangelo Edessa" svg:font-family="'Estrangelo Edessa'" style:font-pitch="variable"/><style:font-face style:name="MS Mincho" svg:font-family="'MS Mincho'" style:font-pitch="variable"/><style:font-face style:name="Miriam CLM" svg:font-family="'Miriam CLM'" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-pitch="variable"/><style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="Tabella1" style:family="table"><style:table-properties style:width="6.6924in" table:align="margins"/></style:style><style:style style:name="Tabella1.A" style:family="table-column"><style:table-column-properties style:column-width="4.8556in" style:rel-column-width="47546*"/></style:style><style:style style:name="Tabella1.B" style:family="table-column"><style:table-column-properties style:column-width="1.8368in" style:rel-column-width="17989*"/></style:style><style:style style:name="Tabella1.A1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="none" fo:border-top="0.0007in solid #000000" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="Tabella1.B1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border="0.0007in solid #000000"/></style:style><style:style style:name="Tabella1.A2" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="Tabella1.B2" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="0.0007in solid #000000" fo:border-top="none" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="Tabella2" style:family="table"><style:table-properties style:width="6.6924in" table:align="margins"/></style:style><style:style style:name="Tabella2.A" style:family="table-column"><style:table-column-properties style:column-width="2.584in" style:rel-column-width="25303*"/></style:style><style:style style:name="Tabella2.C" style:family="table-column"><style:table-column-properties style:column-width="1.5243in" style:rel-column-width="14929*"/></style:style><style:style style:name="Tabella2.A1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="none" fo:border-top="0.0007in solid #000000" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="Tabella2.C1" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border="0.0007in solid #000000"/></style:style><style:style style:name="Tabella2.A2" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="Tabella2.C2" style:family="table-cell"><style:table-cell-properties fo:padding="0.0382in" fo:border-left="0.0007in solid #000000" fo:border-right="0.0007in solid #000000" fo:border-top="none" fo:border-bottom="0.0007in solid #000000"/></style:style><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Table_20_Heading"><style:text-properties style:font-name="Estrangelo Edessa" fo:font-style="italic" fo:font-weight="bold" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style><style:style style:name="P2" style:family="paragraph" style:parent-style-name="Table_20_Heading"><style:paragraph-properties fo:padding="0.0193in" fo:border="0.0008in solid #000000" style:shadow="none"/><style:text-properties style:font-name="Estrangelo Edessa" fo:font-style="italic" fo:font-weight="bold" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style><style:style style:name="P3" style:family="paragraph" style:parent-style-name="Table_20_Contents"><style:text-properties fo:color="#ff0000" style:font-name="Miriam CLM" fo:font-style="italic" fo:font-weight="bold" style:font-style-asian="italic" style:font-weight-asian="bold" style:font-style-complex="italic" style:font-weight-complex="bold"/></style:style></office:automatic-styles><office:body><office:text><office:forms form:automatic-focus="false" form:apply-design-mode="false"/><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard">Other text Silvio Berlusconi, le ricordo che ha in prestito i seguenti libri</text:p><text:p text:style-name="Standard"/><table:table table:name="Tabella1" table:style-name="Tabella1"><table:table-column table:style-name="Tabella1.A"/><table:table-column table:style-name="Tabella1.B"/><table:table-header-rows><table:table-row><table:table-cell table:style-name="Tabella1.A1" office:value-type="string"><text:p text:style-name="P1">Titolo</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B1" office:value-type="string"><text:p text:style-name="P1">Inventario</text:p></table:table-cell></table:table-row></table:table-header-rows><table:table-row><table:table-cell table:style-name="Tabella1.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Codice Da Vinci</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B2" office:value-type="string"><text:p text:style-name="Table_20_Contents">112345678</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella1.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Lo Zen e il tiro con l'arco</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B2" office:value-type="string"><text:p text:style-name="Table_20_Contents">1020304</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella1.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Lo Zen e l'arte della manutenzione della motocicletta</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B2" office:value-type="string"><text:p text:style-name="Table_20_Contents">1020305</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella1.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">101 Storie Zen</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B2" office:value-type="string"><text:p text:style-name="Table_20_Contents">1020306</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella1.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Antani di Blinda come fosse di Cappotto</text:p></table:table-cell><table:table-cell table:style-name="Tabella1.B2" office:value-type="string"><text:p text:style-name="Table_20_Contents">4112345</text:p></table:table-cell></table:table-row></table:table><text:p text:style-name="Standard"/><text:p text:style-name="Standard">peraltro, sottolineiamo la perentorietà della restituzione anche dei vieppiù interessanti testi:</text:p><text:p text:style-name="Standard"/><table:table table:name="Tabella2" table:style-name="Tabella2"><table:table-column table:style-name="Tabella2.A" table:number-columns-repeated="2"/><table:table-column table:style-name="Tabella2.C"/><table:table-header-rows><table:table-row><table:table-cell table:style-name="Tabella2.A1" office:value-type="string"><text:p text:style-name="P2">Titolo</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A1" office:value-type="string"><text:p text:style-name="P2">Autore</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C1" office:value-type="string"><text:p text:style-name="P2">Inventario</text:p></table:table-cell></table:table-row></table:table-header-rows><table:table-row><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Angeli e Demoni</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="P3">Dan Brown</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C2" office:value-type="string"><text:p text:style-name="Table_20_Contents">12131415</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">La versione di Barney</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="P3">Mordecai Richler</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C2" office:value-type="string"><text:p text:style-name="Table_20_Contents">2010322</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">Manuale PHP</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="P3">Varii</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C2" office:value-type="string"><text:p text:style-name="Table_20_Contents">32413543</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">La prematurata supercazzola negli anni a venire</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="P3">Ugo Tognazzi</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C2" office:value-type="string"><text:p text:style-name="Table_20_Contents">31213243</text:p></table:table-cell></table:table-row><table:table-row><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="Table_20_Contents">La sbiriguda in vicesindaco</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.A2" office:value-type="string"><text:p text:style-name="P3">Ugo Tognazzi</text:p></table:table-cell><table:table-cell table:style-name="Tabella2.C2" office:value-type="string"><text:p text:style-name="Table_20_Contents">1324354654</text:p></table:table-cell></table:table-row></table:table><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard">Gentili saluti, la sua biblioteca</text:p></office:text></office:body></office:document-content> diff --git a/ext/zip/tests/bug8009.phpt b/ext/zip/tests/bug8009.phpt new file mode 100644 index 000000000..dd396ebb9 --- /dev/null +++ b/ext/zip/tests/bug8009.phpt @@ -0,0 +1,27 @@ +--TEST-- +bug #8009, cannot add again same entry to an archive +--SKIPIF-- +<?php +/* $Id: bug8009.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$thisdir = dirname(__FILE__); +$src = $thisdir . "/bug8009.zip"; +$filename = $thisdir . "/tmp8009.zip"; +copy($src, $filename); + +$zip = new ZipArchive(); + +if (!$zip->open($filename)) { + exit("cannot open $filename\n"); +} +$zip->addFromString("2.txt", "=)"); +$zip->close(); +unlink($filename); +echo "status: " . $zip->status . "\n"; +echo "\n"; + +--EXPECT-- +status: 0 diff --git a/ext/zip/tests/bug8009.zip b/ext/zip/tests/bug8009.zip Binary files differnew file mode 100644 index 000000000..45bedcbe8 --- /dev/null +++ b/ext/zip/tests/bug8009.zip diff --git a/ext/zip/tests/bug8700.phpt b/ext/zip/tests/bug8700.phpt new file mode 100644 index 000000000..2749404ce --- /dev/null +++ b/ext/zip/tests/bug8700.phpt @@ -0,0 +1,30 @@ +--TEST-- +bug #8700, getFromIndex(0) fails +--SKIPIF-- +<?php +/* $Id: bug8700.phpt,v 1.1.2.2 2006/09/15 12:12:25 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$thisdir = dirname(__FILE__); +$filename = $thisdir . "/bug8009.zip"; + +$zip = new ZipArchive(); + +if ($zip->open($filename) === FALSE) { + exit("cannot open $filename\n"); +} +$contents_from_idx = $zip->getFromIndex(0); +$contents_from_name = $zip->getFromName('1.txt'); +if ($contents_from_idx != $contents_from_name) { + echo "failed:"; + var_dump($content_from_idx, $content_from_name); +} + +$zip->close(); +echo "status: " . $zip->status . "\n"; +echo "\n"; + +--EXPECT-- +status: 0 diff --git a/ext/zip/tests/oo_addfile.phpt b/ext/zip/tests/oo_addfile.phpt new file mode 100644 index 000000000..aee615416 --- /dev/null +++ b/ext/zip/tests/oo_addfile.phpt @@ -0,0 +1,37 @@ +--TEST-- +ziparchive::addFile() function +--SKIPIF-- +<?php +/* $Id: oo_addfile.phpt,v 1.1.2.1 2006/10/02 14:31:04 tony2001 Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_oo_addfile.zip'; + +copy($dirname . 'test.zip', $file); + +$zip = new ZipArchive; +if (!$zip->open($file)) { + exit('failed'); +} +if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) { + echo "failed\n"; +} +if ($zip->status == ZIPARCHIVE::ER_OK) { + dump_entries_name($zip); + $zip->close(); +} else { + echo "failed\n"; +} +@unlink($file); +?> +--EXPECTF-- +0 bar +1 foobar/ +2 foobar/baz +3 entry1.txt +4 test.php diff --git a/ext/zip/tests/oo_close.phpt b/ext/zip/tests/oo_close.phpt new file mode 100644 index 000000000..42b755610 --- /dev/null +++ b/ext/zip/tests/oo_close.phpt @@ -0,0 +1,25 @@ +--TEST-- +zip::close() function +--SKIPIF-- +<?php +/* $Id: oo_close.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +$dirname = dirname(__FILE__) . '/'; +$zip = new ZipArchive; +if (!$zip->open($dirname . 'test.zip')) { + exit('failed'); +} + +if ($zip->status == ZIPARCHIVE::ER_OK) { + $zip->close(); + echo "ok\n"; +} else { + echo "failed\n"; +} +?> +--EXPECTF-- +ok diff --git a/ext/zip/tests/oo_delete.phpt b/ext/zip/tests/oo_delete.phpt new file mode 100644 index 000000000..902fad244 --- /dev/null +++ b/ext/zip/tests/oo_delete.phpt @@ -0,0 +1,76 @@ +--TEST-- +Delete entries +--SKIPIF-- +<?php +/* $Id: oo_delete.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +$file = $dirname . '__tmp_oo_delete.zip'; +if (file_exists($file)) { + unlink($file); +} + +$zip = new ZipArchive; +if (!$zip->open($file, ZIPARCHIVE::CREATE)) { + exit('failed'); +} +$zip->addFromString('entry1.txt', 'entry #1'); +$zip->addFromString('entry2.txt', 'entry #2'); +$zip->addFromString('dir/entry2.txt', 'entry #2'); + +if ($zip->status == ZIPARCHIVE::ER_OK) { + $zip->close(); + echo "ok\n"; +} else { + var_dump($zip); + echo "failed\n"; +} + +if (!$zip->open($file, ZIPARCHIVE::CREATE)) { + exit('failed'); +} + +if ($zip->deleteIndex(0)) { + echo "ok\n"; +} + +if ($zip->deleteName('entry2.txt')) { + echo "ok\n"; +} else { + echo "failed 3\n"; +} + +if ($zip->deleteName('dir/entry2.txt')) { + echo "ok\n"; +} else { + echo "failed 3\n"; +} + +if (!$zip->deleteIndex(123)) { + echo "ok\n"; +} else { + print_r($zip); + echo "failed\n"; +} + + +$sb = $zip->statIndex(0); +var_dump($sb); +$sb = $zip->statIndex(1); +var_dump($sb); +$sb = $zip->statIndex(2); +var_dump($sb); +@unlink($file); +?> +--EXPECTF-- +ok +ok +ok +ok +ok +bool(false) +bool(false) +bool(false) diff --git a/ext/zip/tests/oo_ext_zip.phpt b/ext/zip/tests/oo_ext_zip.phpt new file mode 100644 index 000000000..e911ce8f3 --- /dev/null +++ b/ext/zip/tests/oo_ext_zip.phpt @@ -0,0 +1,27 @@ +--TEST-- +Extending Zip class and array property +--SKIPIF-- +<?php +/* $Id: oo_ext_zip.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?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; +?> +--EXPECTF-- +array(1) { + [0]=> + int(1) +} diff --git a/ext/zip/tests/oo_namelocate.phpt b/ext/zip/tests/oo_namelocate.phpt new file mode 100644 index 000000000..72ac6318a --- /dev/null +++ b/ext/zip/tests/oo_namelocate.phpt @@ -0,0 +1,46 @@ +--TEST-- +Locate entries by name +--SKIPIF-- +<?php +/* $Id: oo_namelocate.phpt,v 1.1.2.2 2006/10/02 14:31:04 tony2001 Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_oo_rename.zip'; + +@unlink($file); + +$zip = new ZipArchive; +if (!$zip->open($file, ZIPARCHIVE::CREATE)) { + exit('failed'); +} + +$zip->addFromString('entry1.txt', 'entry #1'); +$zip->addFromString('entry2.txt', 'entry #2'); +$zip->addFromString('dir/entry2d.txt', 'entry #2'); + +if (!$zip->status == ZIPARCHIVE::ER_OK) { + echo "failed to write zip\n"; +} +$zip->close(); + +if (!$zip->open($file)) { + exit('failed'); +} + + +var_dump($zip->locateName('entry1.txt')); +var_dump($zip->locateName('eNtry2.txt')); +var_dump($zip->locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE)); +var_dump($zip->locateName('enTRy2d.txt', ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR)); +$zip->close(); + +?> +--EXPECTF-- +int(0) +bool(false) +int(1) +int(2) diff --git a/ext/zip/tests/oo_open.phpt b/ext/zip/tests/oo_open.phpt new file mode 100644 index 000000000..9934016fa --- /dev/null +++ b/ext/zip/tests/oo_open.phpt @@ -0,0 +1,46 @@ +--TEST-- +zip::open() function +--SKIPIF-- +<?php +/* $Id: oo_open.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php + +$dirname = dirname(__FILE__) . '/'; +$zip = new ZipArchive; +$r = $zip->open($dirname . 'nofile'); +if ($r !== TRUE) { + echo "ER_OPEN: ok\n"; +} else { + echo "ER_OPEN: FAILED\n"; +} + +$r = $zip->open($dirname . 'nofile', ZIPARCHIVE::CREATE); +if (!$r) { + echo "create: failed\n"; +} else { + echo "create: ok\n"; +} +@unlink($dirname . 'nofile'); + +$zip = new ZipArchive; +$zip->open(''); + +if (!$zip->open($dirname . 'test.zip')) { + exit("failed 1\n"); +} + +if ($zip->status == ZIPARCHIVE::ER_OK) { + echo "OK\n"; +} else { + echo "failed\n"; +} +?> +--EXPECTF-- +ER_OPEN: ok +create: ok + +Warning: ZipArchive::open(): Empty string as source in %s on line %d +OK diff --git a/ext/zip/tests/oo_rename.phpt b/ext/zip/tests/oo_rename.phpt new file mode 100644 index 000000000..ac44146fc --- /dev/null +++ b/ext/zip/tests/oo_rename.phpt @@ -0,0 +1,58 @@ +--TEST-- +Rename entries +--SKIPIF-- +<?php +/* $Id: oo_rename.phpt,v 1.1.2.1 2006/10/02 14:31:04 tony2001 Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_oo_rename.zip'; + +@unlink($file); + +$zip = new ZipArchive; +if (!$zip->open($file, ZIPARCHIVE::CREATE)) { + exit('failed'); +} + +$zip->addFromString('entry1.txt', 'entry #1'); +$zip->addFromString('entry2.txt', 'entry #2'); +$zip->addFromString('dir/entry2.txt', 'entry #2'); + +if (!$zip->status == ZIPARCHIVE::ER_OK) { + var_dump($zip); + echo "failed\n"; +} + +$zip->close(); + +if (!$zip->open($file)) { + exit('failed'); +} + +dump_entries_name($zip); +echo "\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); +$zip->close(); + +@unlink($file); +?> +--EXPECTF-- +0 entry1.txt +1 entry2.txt +2 dir/entry2.txt + +0 ren_entry1.txt +1 entry2.txt +2 dir3/ren_entry2.txt diff --git a/ext/zip/tests/test.zip b/ext/zip/tests/test.zip Binary files differnew file mode 100644 index 000000000..35bd5eecd --- /dev/null +++ b/ext/zip/tests/test.zip diff --git a/ext/zip/tests/test_procedural.zip b/ext/zip/tests/test_procedural.zip Binary files differnew file mode 100644 index 000000000..6b9869480 --- /dev/null +++ b/ext/zip/tests/test_procedural.zip diff --git a/ext/zip/tests/utils.inc b/ext/zip/tests/utils.inc new file mode 100644 index 000000000..7a8b5a122 --- /dev/null +++ b/ext/zip/tests/utils.inc @@ -0,0 +1,8 @@ +<?php +/* $Id: utils.inc,v 1.1.2.2 2006/10/02 14:17:47 bjori Exp $ */ +function dump_entries_name($z) { + for($i=0; $i<$z->numFiles; $i++) { + $sb = $z->statIndex($i); + echo $i . ' ' . $sb['name'] . "\n"; + } +} diff --git a/ext/zip/tests/zip_close.phpt b/ext/zip/tests/zip_close.phpt new file mode 100644 index 000000000..d7259b3da --- /dev/null +++ b/ext/zip/tests/zip_close.phpt @@ -0,0 +1,17 @@ +--TEST-- +zip_close() function +--SKIPIF-- +<?php +/* $Id: zip_close.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +zip_close($zip); +echo "OK"; + +?> +--EXPECT-- +OK diff --git a/ext/zip/tests/zip_entry_compressedsize.phpt b/ext/zip/tests/zip_entry_compressedsize.phpt new file mode 100644 index 000000000..5e0fd9c45 --- /dev/null +++ b/ext/zip/tests/zip_entry_compressedsize.phpt @@ -0,0 +1,23 @@ +--TEST-- +zip_entry_compressedsize() function +--SKIPIF-- +<?php +/* $Id: zip_entry_compressedsize.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +while ($entry = zip_read($zip)) { + echo zip_entry_compressedsize($entry)."\n"; +} +zip_close($zip); + +?> +--EXPECT-- +5 +4 +0 +24 diff --git a/ext/zip/tests/zip_entry_compressionmethod.phpt b/ext/zip/tests/zip_entry_compressionmethod.phpt new file mode 100644 index 000000000..d505a633b --- /dev/null +++ b/ext/zip/tests/zip_entry_compressionmethod.phpt @@ -0,0 +1,24 @@ +--TEST-- +zip_entry_compressionmethod() function +--SKIPIF-- +<?php +/* $Id: zip_entry_compressionmethod.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +while ($entry = zip_read($zip)) { + echo zip_entry_compressionmethod($entry)."\n"; +} +zip_close($zip); + +?> +--EXPECT-- +stored +stored +stored +deflated + diff --git a/ext/zip/tests/zip_entry_filesize.phpt b/ext/zip/tests/zip_entry_filesize.phpt new file mode 100644 index 000000000..d87506271 --- /dev/null +++ b/ext/zip/tests/zip_entry_filesize.phpt @@ -0,0 +1,23 @@ +--TEST-- +zip_entry_filesize() function +--SKIPIF-- +<?php +/* $Id: zip_entry_filesize.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +while ($entry = zip_read($zip)) { + echo zip_entry_filesize($entry)."\n"; +} +zip_close($zip); + +?> +--EXPECT-- +5 +4 +0 +27 diff --git a/ext/zip/tests/zip_entry_name.phpt b/ext/zip/tests/zip_entry_name.phpt new file mode 100644 index 000000000..b47c89fdb --- /dev/null +++ b/ext/zip/tests/zip_entry_name.phpt @@ -0,0 +1,23 @@ +--TEST-- +zip_entry_name() function +--SKIPIF-- +<?php +/* $Id: zip_entry_name.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +while ($entry = zip_read($zip)) { + echo zip_entry_name($entry)."\n"; +} +zip_close($zip); + +?> +--EXPECT-- +foo +bar +foobar/ +foobar/baz diff --git a/ext/zip/tests/zip_entry_open.phpt b/ext/zip/tests/zip_entry_open.phpt new file mode 100644 index 000000000..4e0100357 --- /dev/null +++ b/ext/zip/tests/zip_entry_open.phpt @@ -0,0 +1,17 @@ +--TEST-- +zip_entry_open() function +--SKIPIF-- +<?php +/* $Id: zip_entry_open.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +$entry = zip_read($zip); +echo zip_entry_open($zip, $entry, "r") ? "OK" : "Failure"; +zip_close($zip); + +?> +--EXPECT-- +OK diff --git a/ext/zip/tests/zip_entry_read.phpt b/ext/zip/tests/zip_entry_read.phpt new file mode 100644 index 000000000..f72b5e2cb --- /dev/null +++ b/ext/zip/tests/zip_entry_read.phpt @@ -0,0 +1,18 @@ +--TEST-- +zip_entry_read() function +--SKIPIF-- +<?php +/* $Id: zip_entry_read.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +$entry = zip_read($zip); +if (!zip_entry_open($zip, $entry, "r")) die("Failure"); +echo zip_entry_read($entry); +zip_close($zip); + +?> +--EXPECT-- +foo diff --git a/ext/zip/tests/zip_open.phpt b/ext/zip/tests/zip_open.phpt new file mode 100644 index 000000000..6306543bc --- /dev/null +++ b/ext/zip/tests/zip_open.phpt @@ -0,0 +1,16 @@ +--TEST-- +zip_open() function +--SKIPIF-- +<?php +/* $Id: zip_open.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); + +echo is_resource($zip) ? "OK" : "Failure"; + +?> +--EXPECT-- +OK diff --git a/ext/zip/tests/zip_read.phpt b/ext/zip/tests/zip_read.phpt new file mode 100644 index 000000000..126fc8bda --- /dev/null +++ b/ext/zip/tests/zip_read.phpt @@ -0,0 +1,21 @@ +--TEST-- +zip_read() function +--SKIPIF-- +<?php +/* $Id: zip_read.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$zip = zip_open(dirname(__FILE__)."/test_procedural.zip"); +if (!is_resource($zip)) die("Failure"); +$entries = 0; +while ($entry = zip_read($zip)) { + $entries++; +} +zip_close($zip); +echo "$entries entries"; + +?> +--EXPECT-- +4 entries |
