summaryrefslogtreecommitdiff
path: root/ext/zip/tests/oo_properties.phpt
blob: 886317b57bbe9175b46d825d42b9414434676fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--TEST--
ziparchive::properties isset()/empty() checks
--SKIPIF--
<?php
/* $Id$ */
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php

$dirname = dirname(__FILE__) . '/';
$file = $dirname . '__property_test.zip';

copy($dirname . 'test_with_comment.zip', $file);

$zip = new ZipArchive;
if (!$zip->open($file)) {
	exit('failed');
}

printf("zip->status (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->status, empty($zip->status), isset($zip->status));
printf("zip->numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->numFiles, empty($zip->numFiles), isset($zip->numFiles));
printf("zip->bogus (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->bogus, empty($zip->bogus), isset($zip->bogus));


$zip->addEmptyDir('emptydir');

printf("zip->status (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->status, empty($zip->status), isset($zip->status));
printf("zip->numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n", $zip->numFiles, empty($zip->numFiles), isset($zip->numFiles));
printf("zip->filename (%d):\n\tempty(): %d\n\tisset(): %d\n", strlen($zip->filename), empty($zip->filename), isset($zip->filename));
printf("zip->comment (%d):\n\tempty(): %d\n\tisset(): %d\n", strlen($zip->comment), empty($zip->comment), isset($zip->comment));

unset($zip); //close the file before unlinking
@unlink($file);
?>
--EXPECTF--
zip->status (0):
	empty(): 1
	isset(): 1
zip->numFiles (4):
	empty(): 0
	isset(): 1

Notice: Undefined property: ZipArchive::$bogus in %s on line %d
zip->bogus (0):
	empty(): 1
	isset(): 0
zip->status (0):
	empty(): 1
	isset(): 1
zip->numFiles (5):
	empty(): 0
	isset(): 1
zip->filename (%d):
	empty(): 0
	isset(): 1
zip->comment (19):
	empty(): 0
	isset(): 1