xref: /PHP-7.1/ext/zip/tests/oo_open.phpt (revision 664d102a)
1--TEST--
2zip::open() function
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10
11$dirname = dirname(__FILE__) . '/';
12$zip = new ZipArchive;
13$r = $zip->open($dirname . 'nofile');
14if ($r !== TRUE) {
15	echo "ER_OPEN: ok\n";
16} else {
17	echo "ER_OPEN: FAILED\n";
18}
19
20$r = $zip->open($dirname . 'nofile', ZIPARCHIVE::CREATE);
21if (!$r) {
22	echo "create: failed\n";
23} else {
24	echo "create: ok\n";
25}
26@unlink($dirname . 'nofile');
27
28$zip = new ZipArchive;
29$zip->open('');
30
31if (!$zip->open($dirname . 'test.zip')) {
32	exit("failed 1\n");
33}
34
35if ($zip->status == ZIPARCHIVE::ER_OK) {
36	echo "OK\n";
37} else {
38	echo "failed\n";
39}
40?>
41--EXPECTF--
42ER_OPEN: ok
43create: ok
44
45Warning: ZipArchive::open(): Empty string as source in %s on line %d
46OK
47