xref: /PHP-8.1/ext/zip/tests/bug72374.phpt (revision 74859783)
1--TEST--
2Bug #72374 (ZipArchive::addGlob remove_path option strips first char of filename)
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7$dirname = dirname(__FILE__) . '/';
8include $dirname . 'utils.inc';
9
10$dirname = $dirname . 'bug72374';
11mkdir($dirname);
12$file1 = $dirname . '/some-foo.txt';
13touch($file1);
14$file2 = $dirname . '/some-bar.txt';
15touch($file2);
16
17$zip = new ZipArchive();
18$zip->open($dirname . '/test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
19$zip->addGlob($file1, 0, array('remove_path' => $dirname . '/some-'));
20$zip->addGlob($file1, 0, array('remove_path' => $dirname . '/'));
21$zip->addGlob($file2, 0, array('remove_path' => $dirname));
22verify_entries($zip, ['foo.txt', 'some-foo.txt', 'some-bar.txt']);
23$zip->close();
24?>
25--CLEAN--
26<?php
27$dirname = dirname(__FILE__) . '/';
28include $dirname . 'utils.inc';
29
30$dirname = $dirname . 'bug72374';
31rmdir_rf($dirname);
32?>
33--EXPECT--
34