xref: /PHP-8.0/ext/zip/tests/bug70322.phpt (revision c836ad1c)
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--SKIPIF--
8<?php
9if (!extension_loaded('zip')) die('skip requires zip extension');
10?>
11--FILE--
12<?php
13$zipfile = __DIR__ . '/bug70322.zip';
14$textfile = __DIR__ . '/bug70322.txt';
15touch($textfile);
16$zip = new ZipArchive();
17$zip->open($zipfile, ZipArchive::CREATE);
18$zip->addFile($textfile);
19unlink($textfile);
20var_dump($zip->close());
21?>
22--CLEAN--
23<?php
24// we don't expect the archive to be created, but clean up just in case...
25@unlink(__DIR__ . '/bug70322.zip');
26?>
27--EXPECTF--
28Warning: ZipArchive::close(): %s: No such file or directory in %s%ebug70322.php on line %d
29bool(false)
30