xref: /PHP-8.1/ext/zip/tests/bug80863.phpt (revision 74859783)
1--TEST--
2Bug #80863 (ZipArchive::extractTo() ignores references)
3--EXTENSIONS--
4zip
5--FILE--
6<?php
7$archive = __DIR__ . "/bug80863.zip";
8
9$zip = new ZipArchive();
10$zip->open($archive, ZipArchive::CREATE | ZipArchive::OVERWRITE);
11$zip->addFromString("file1.txt", "contents");
12$zip->addFromString("file2.txt", "contents");
13$zip->close();
14
15$target = __DIR__ . "/bug80683";
16mkdir($target);
17
18$files = [
19    "file1.txt",
20    "file2.txt",
21];
22// turn into references
23foreach ($files as &$file);
24
25$zip = new ZipArchive();
26$zip->open($archive);
27$zip->extractTo($target, $files);
28var_dump(is_file("$target/file1.txt"));
29var_dump(is_file("$target/file2.txt"));
30?>
31--EXPECT--
32bool(true)
33bool(true)
34--CLEAN--
35<?php
36@unlink(__DIR__ . "/bug80863.zip");
37$target = __DIR__ .  "/bug80683";
38@unlink("$target/file1.txt");
39@unlink("$target/file2.txt");
40@rmdir($target);
41?>
42