xref: /PHP-8.1/ext/zip/tests/bug70103.phpt (revision 74859783)
1--TEST--
2Bug #70103 (ZipArchive::addGlob ignores remove_all_path option)
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7$dir = __DIR__ . '/bug70103';
8
9mkdir($dir); chmod($dir, 0777);
10file_put_contents($dir . '/foo.txt', 'foo');
11
12$zip = new ZipArchive();
13$zip->open($dir . '/test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
14$zip->addGlob($dir . '/*.txt', GLOB_NOSORT, array('remove_all_path' => true));
15$zip->close();
16
17$zip = new ZipArchive();
18$zip->open($dir . '/test.zip');
19var_dump($zip->numFiles);
20var_dump($zip->getNameIndex(0));
21$zip->close();
22?>
23--CLEAN--
24<?php
25$dir = __DIR__ . '/bug70103';
26unlink($dir . '/foo.txt');
27unlink($dir . '/test.zip');
28rmdir($dir);
29?>
30--EXPECT--
31int(1)
32string(7) "foo.txt"
33