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