xref: /PHP-7.3/ext/zip/tests/bug64342_0.phpt (revision 02e4d7a2)
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(dirname(__FILE__) . '/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(dirname(__FILE__) . '/bug64342.zip');
38--EXPECTF--
39%s.txt
40add failed
41close ok
42DONE
43