Skip to content

Commit 567f5e5

Browse files
committed
Merge remote-tracking branch 'origin/master' into str_size_and_int64
* origin/master: Added tests for ZipArchive::addGlob() and ZipArchive::addPattern() gcov: tentative fix for broken coverage data after fix for opcache coverage slightly hackish, but works. The idea is that we want to give priority to .gcda files in .libs dirs vs the files in the upper level dir fix test
2 parents a4a5e34 + 347b430 commit 567f5e5

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

ext/zip/tests/oo_addglob.phpt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
ZipArchive::addGlob() method
3+
--CREDITS--
4+
Sammy Kaye Powers <[email protected]>
5+
w/Kenzo over the shoulder
6+
#phptek Chicago 2014
7+
--SKIPIF--
8+
<?php
9+
/* $Id$ */
10+
if(!extension_loaded('zip')) die('skip');
11+
?>
12+
--FILE--
13+
<?php
14+
$dirname = dirname(__FILE__) . '/';
15+
include $dirname . 'utils.inc';
16+
$file = $dirname . '__tmp_oo_addglob.zip';
17+
18+
copy($dirname . 'test.zip', $file);
19+
touch($dirname . 'foo.txt');
20+
touch($dirname . 'bar.baz');
21+
22+
$zip = new ZipArchive();
23+
if (!$zip->open($file)) {
24+
exit('failed');
25+
}
26+
$options = array('add_path' => 'baz/', 'remove_all_path' => TRUE);
27+
if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) {
28+
echo "failed1\n";
29+
}
30+
if ($zip->status == ZIPARCHIVE::ER_OK) {
31+
dump_entries_name($zip);
32+
$zip->close();
33+
} else {
34+
echo "failed2\n";
35+
}
36+
?>
37+
--CLEAN--
38+
<?php
39+
$dirname = dirname(__FILE__) . '/';
40+
unlink($dirname . '__tmp_oo_addglob.zip');
41+
unlink($dirname . 'foo.txt');
42+
unlink($dirname . 'bar.baz');
43+
?>
44+
--EXPECTF--
45+
0 bar
46+
1 foobar/
47+
2 foobar/baz
48+
3 entry1.txt
49+
4 baz/foo.txt
50+
5 baz/bar.baz

ext/zip/tests/oo_addpattern.phpt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
ZipArchive::addPattern() method
3+
--CREDITS--
4+
Sammy Kaye Powers <[email protected]>
5+
w/Kenzo over the shoulder
6+
#phptek Chicago 2014
7+
--SKIPIF--
8+
<?php
9+
/* $Id$ */
10+
if(!extension_loaded('zip')) die('skip');
11+
?>
12+
--FILE--
13+
<?php
14+
$dirname = dirname(__FILE__) . '/';
15+
include $dirname . 'utils.inc';
16+
$file = $dirname . '__tmp_oo_addpattern.zip';
17+
18+
copy($dirname . 'test.zip', $file);
19+
touch($dirname . 'foo.txt');
20+
touch($dirname . 'bar.txt');
21+
22+
$zip = new ZipArchive();
23+
if (!$zip->open($file)) {
24+
exit('failed');
25+
}
26+
$dir = realpath($dirname);
27+
$options = array('add_path' => 'baz/', 'remove_path' => $dir);
28+
if (!$zip->addPattern('/\.txt$/', $dir, $options)) {
29+
echo "failed\n";
30+
}
31+
if ($zip->status == ZIPARCHIVE::ER_OK) {
32+
dump_entries_name($zip);
33+
$zip->close();
34+
} else {
35+
echo "failed\n";
36+
}
37+
?>
38+
--CLEAN--
39+
<?php
40+
$dirname = dirname(__FILE__) . '/';
41+
unlink($dirname . '__tmp_oo_addpattern.zip');
42+
unlink($dirname . 'foo.txt');
43+
unlink($dirname . 'bar.txt');
44+
?>
45+
--EXPECTF--
46+
0 bar
47+
1 foobar/
48+
2 foobar/baz
49+
3 entry1.txt
50+
4 baz/bar.txt
51+
5 baz/foo.txt

0 commit comments

Comments
 (0)