xref: /PHP-7.0/ext/zip/tests/oo_addglob.phpt (revision ed5a5bdf)
1--TEST--
2ZipArchive::addGlob() method
3--CREDITS--
4Sammy Kaye Powers <sammyk@sammykmedia.com>
5w/Kenzo over the shoulder
6#phptek Chicago 2014
7--SKIPIF--
8<?php
9/* $Id$ */
10if(!extension_loaded('zip')) die('skip');
11if(!defined("GLOB_BRACE")) die ('skip');
12?>
13--FILE--
14<?php
15$dirname = dirname(__FILE__) . '/';
16include $dirname . 'utils.inc';
17$file = $dirname . '__tmp_oo_addglob.zip';
18
19copy($dirname . 'test.zip', $file);
20touch($dirname . 'foo.txt');
21touch($dirname . 'bar.baz');
22
23$zip = new ZipArchive();
24if (!$zip->open($file)) {
25        exit('failed');
26}
27$options = array('add_path' => 'baz/', 'remove_all_path' => TRUE);
28if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) {
29        echo "failed1\n";
30}
31if ($zip->status == ZIPARCHIVE::ER_OK) {
32        dump_entries_name($zip);
33        $zip->close();
34} else {
35        echo "failed2\n";
36}
37?>
38--CLEAN--
39<?php
40$dirname = dirname(__FILE__) . '/';
41unlink($dirname . '__tmp_oo_addglob.zip');
42unlink($dirname . 'foo.txt');
43unlink($dirname . 'bar.baz');
44?>
45--EXPECTF--
460 bar
471 foobar/
482 foobar/baz
493 entry1.txt
504 baz/foo.txt
515 baz/bar.baz
52