xref: /PHP-8.2/ext/zip/tests/bug64342_1.phpt (revision 74859783)
1--TEST--
2Bug #64342 ZipArchive::addFile() has to check file existence (variation 2)
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7
8$dirname = __DIR__ . '/';
9include $dirname . 'utils.inc';
10$file = $dirname . 'bug64342_1.zip';
11
12copy($dirname . 'test.zip', $file);
13
14$zip = new ZipArchive;
15if (!$zip->open($file)) {
16    exit('failed');
17}
18if (!$zip->addFile($dirname . 'cant_find_me.txt', 'test.php')) {
19    echo "failed\n";
20}
21if ($zip->status == ZIPARCHIVE::ER_OK) {
22    if (!verify_entries($zip, [
23        "bar",
24        "foobar/",
25        "foobar/baz",
26        "entry1.txt"
27    ])) {
28        echo "failed\n";
29    } else {
30        echo "OK";
31    }
32    $zip->close();
33} else {
34    echo "failed\n";
35}
36@unlink($file);
37?>
38--EXPECTF--
39Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
40failed
41OK
42