xref: /PHP-8.3/ext/zip/tests/bug70322.phpt (revision 74859783)
1--TEST--
2Bug #70322 (ZipArchive::close() doesn't indicate errors)
3--DESCRIPTION--
4We want to test whether ZipArchive::close() returns FALSE and raises a warning
5on failure, so we force the failure by adding a file to the archive, which we
6delete before closing.
7--EXTENSIONS--
8zip
9--FILE--
10<?php
11$zipfile = __DIR__ . '/bug70322.zip';
12$textfile = __DIR__ . '/bug70322.txt';
13touch($textfile);
14$zip = new ZipArchive();
15$zip->open($zipfile, ZipArchive::CREATE);
16$zip->addFile($textfile);
17unlink($textfile);
18var_dump($zip->close());
19?>
20--CLEAN--
21<?php
22// we don't expect the archive to be created, but clean up just in case...
23@unlink(__DIR__ . '/bug70322.zip');
24?>
25--EXPECTF--
26Warning: ZipArchive::close(): %s: No such file or directory in %s%ebug70322.php on line %d
27bool(false)
28