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