xref: /PHP-8.2/ext/zip/tests/bug51353.phpt (revision 74859783)
1--TEST--
2Bug #51353 ZIP64 problem, archive with 100000 items
3--EXTENSIONS--
4zip
5--SKIPIF--
6<?php
7die('skip the test might get very long, activate it manually');
8--FILE--
9<?php
10/* This test might get very long depending on the mashine it's running on. Therefore
11adding an explicit skip, remove it to run this test. */
12set_time_limit(0);
13
14$base_path = __DIR__;
15
16/* Either we ship a file with 100000 entries which would be >12M big,
17    or create it dynamically. */
18$zip = new ZipArchive;
19$r = $zip->open("$base_path/51353.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
20if ($r) {
21    for ($i = 0; $i < 100000; $i++) {
22        $zip->addFromString("$i.txt", '1');
23    }
24    $zip->close();
25} else {
26    die("failed");
27}
28
29$zip = new ZipArchive;
30$r = $zip->open("$base_path/51353.zip");
31if ($r) {
32    $zip->extractTo("$base_path/51353_unpack");
33    $zip->close();
34
35    $a = glob("$base_path/51353_unpack/*.txt");
36    echo count($a) . "\n";
37} else {
38    die("failed");
39}
40
41echo "OK";
42--CLEAN--
43<?php
44$base_path = __DIR__;
45
46unlink("$base_path/51353.zip");
47
48$a = glob("$base_path/51353_unpack/*.txt");
49foreach($a as $f) {
50    unlink($f);
51}
52rmdir("$base_path/51353_unpack");
53?>
54--EXPECT--
55100000
56OK
57