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