xref: /php-src/ext/zip/tests/doubleclose.phpt (revision 29f98e74)
1--TEST--
2close() called twice
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7
8echo "Procedural\n";
9$zip = zip_open(__DIR__ . '/test.zip');
10if (!is_resource($zip)) {
11    die("Failure");
12}
13var_dump(zip_close($zip));
14try {
15    var_dump(zip_close($zip));
16} catch (TypeError $e) {
17    echo $e->getMessage(), "\n";
18}
19
20echo "Object\n";
21$zip = new ZipArchive();
22if (!$zip->open(__DIR__ . '/test.zip')) {
23    die('Failure');
24}
25if ($zip->status == ZIPARCHIVE::ER_OK) {
26    var_dump($zip->close());
27    try {
28        $zip->close();
29    } catch (ValueError $err) {
30        echo $err->getMessage(), PHP_EOL;
31    }
32} else {
33    die("Failure");
34}
35
36?>
37Done
38--EXPECTF--
39Procedural
40
41Deprecated: Function zip_open() is deprecated since 8.0, use ZipArchive::open() instead in %s on line %d
42
43Deprecated: Function zip_close() is deprecated since 8.0, use ZipArchive::close() instead in %s on line %d
44NULL
45
46Deprecated: Function zip_close() is deprecated since 8.0, use ZipArchive::close() instead in %s on line %d
47zip_close(): supplied resource is not a valid Zip Directory resource
48Object
49bool(true)
50Invalid or uninitialized Zip object
51Done
52