xref: /PHP-5.5/ext/zip/tests/bug47667.phpt (revision fa197ab9)
1--TEST--
2Bug #47667 (ZipArchive::OVERWRITE seems to have no effect)
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$thisdir = dirname(__FILE__);
11$filename = $thisdir . "/bug47667.zip";
12
13$zip = new ZipArchive();
14if ($zip->open($filename, ZipArchive::CREATE) !== true) {
15	exit("Unable to open the zip file");
16} else {
17	$zip->addFromString('foo.txt', 'foo bar foobar');
18	$zip->close();
19}
20
21for ($i = 0; $i < 10; $i++) {
22	$zip = new ZipArchive();
23	if ($zip->open($filename, ZipArchive::OVERWRITE) !== true) {
24		exit("Unable to open the zip file");
25	}
26	$zip->addFromString("foo_{$i}.txt", 'foo bar foobar');
27	$zip->close();
28}
29
30$zip = new ZipArchive();
31if ($zip->open($filename, ZipArchive::CREATE) !== true) {
32	exit("Unable to open the zip file");
33}
34
35echo "files: " , $zip->numFiles;
36$zip->close();
37
38unlink($filename);
39
40--EXPECT--
41files: 1
42