xref: /PHP-7.3/ext/zip/tests/oo_properties.phpt (revision b746e698)
1--TEST--
2ziparchive::properties isset()/empty() checks
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip');
6?>
7--FILE--
8<?php
9
10$dirname = dirname(__FILE__) . '/';
11$file = $dirname . '__property_test.zip';
12
13copy($dirname . 'test_with_comment.zip', $file);
14
15$zip = new ZipArchive;
16if (!$zip->open($file)) {
17	exit('failed');
18}
19
20printf("zip->status (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->status, empty($zip->status), isset($zip->status));
21printf("zip->numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->numFiles, empty($zip->numFiles), isset($zip->numFiles));
22printf("zip->bogus (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->bogus, empty($zip->bogus), isset($zip->bogus));
23
24
25$zip->addEmptyDir('emptydir');
26
27printf("zip->status (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->status, empty($zip->status), isset($zip->status));
28printf("zip->numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->numFiles, empty($zip->numFiles), isset($zip->numFiles));
29printf("zip->filename (%d):\n\tempty(): %d\n\tisset(): %d\n", strlen($zip->filename), empty($zip->filename), isset($zip->filename));
30printf("zip->comment (%d):\n\tempty(): %d\n\tisset(): %d\n", strlen($zip->comment), empty($zip->comment), isset($zip->comment));
31
32unset($zip); //close the file before unlinking
33@unlink($file);
34?>
35--EXPECTF--
36zip->status (0):
37	empty(): 1
38	isset(): 1
39zip->numFiles (4):
40	empty(): 0
41	isset(): 1
42
43Notice: Undefined property: ZipArchive::$bogus in %s on line %d
44zip->bogus (0):
45	empty(): 1
46	isset(): 0
47zip->status (0):
48	empty(): 1
49	isset(): 1
50zip->numFiles (5):
51	empty(): 0
52	isset(): 1
53zip->filename (%d):
54	empty(): 0
55	isset(): 1
56zip->comment (19):
57	empty(): 0
58	isset(): 1
59