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