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