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