xref: /PHP-8.3/ext/zip/tests/bug64342_0.phpt (revision 74859783)
1--TEST--
2Bug #64342 ZipArchive::addFile() has to check file existence (variation 1)
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7
8$zip = new ZipArchive;
9$res = $zip->open(__DIR__ . '/bug64342.zip', ZipArchive::CREATE);
10if ($res === TRUE) {
11    $f = md5(uniqid()) . '.txt';
12    echo "$f\n";
13    $res = $zip->addFile($f);
14    if (true == $res) {
15        echo "add ok\n";
16    } else {
17        echo "add failed\n";
18    }
19    $res = $zip->close();
20    if (true == $res) {
21        echo "close ok\n";
22    } else {
23        echo "close failed\n";
24    }
25} else {
26    echo "open failed\n";
27}
28
29
30?>
31DONE
32--CLEAN--
33<?php
34
35@unlink(__DIR__ . '/bug64342.zip');
36?>
37--EXPECTF--
38%s.txt
39
40Warning: ZipArchive::addFile(): No such file or directory in %s on line %d
41add failed
42close ok
43DONE
44