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