xref: /PHP-7.1/ext/zip/tests/oo_delete.phpt (revision c77f7837)
1--TEST--
2Delete entries
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$dirname = dirname(__FILE__) . '/';
11$file = $dirname . '__tmp_oo_delete.zip';
12if (file_exists($file)) {
13	unlink($file);
14}
15
16$zip = new ZipArchive;
17if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
18	exit('failed');
19}
20$zip->addFromString('entry1.txt', 'entry #1');
21$zip->addFromString('entry2.txt', 'entry #2');
22$zip->addFromString('dir/entry2.txt', 'entry #2');
23
24if ($zip->status == ZIPARCHIVE::ER_OK) {
25	$zip->close();
26	echo "ok\n";
27} else {
28	var_dump($zip);
29	echo "failed\n";
30}
31
32if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
33	exit('failed');
34}
35
36if ($zip->deleteIndex(0)) {
37	echo "ok\n";
38}
39
40if ($zip->deleteName('entry2.txt')) {
41	echo "ok\n";
42} else {
43	echo "failed 3\n";
44}
45
46if ($zip->deleteName('dir/entry2.txt')) {
47	echo "ok\n";
48} else {
49	echo "failed 3\n";
50}
51
52if (!$zip->deleteIndex(123)) {
53	echo "ok\n";
54} else {
55	print_r($zip);
56	echo "failed\n";
57}
58
59
60$sb = $zip->statIndex(0);
61var_dump($sb);
62$sb = $zip->statIndex(1);
63var_dump($sb);
64$sb = $zip->statIndex(2);
65var_dump($sb);
66// suppress irrelevant error message:
67@$zip->close();
68unset($zip);
69
70if (file_exists($file)) {
71	unlink($file);
72}
73?>
74--EXPECTF--
75ok
76ok
77ok
78ok
79ok
80bool(false)
81bool(false)
82bool(false)
83