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