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