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