blob: b1106ec59e3f51d9819020dff43b22e8416378f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
declare(strict_types = 1);
namespace Pablotron\ZipStream\Tests;
use \PHPUnit\Framework\TestCase;
use \Pablotron\ZipStream\ZipStream;
final class LargeFileTest extends BaseTestCase {
public function testCreateLargeFile() : void {
# size and number of chunks
$chunk_size = (1 << 22);
$num_chunks = 1025;
# calculate expected file size (4299161600, enough to overflow a
# 32-bit integer and trigger zip64 mode)
$expected_size = $chunk_size * $num_chunks;
$this->with_temp_zip(function(ZipStream &$zip) use ($chunk_size, $num_chunks) {
$zip->add('hello.txt', function($e) use ($chunk_size, $num_chunks) {
# build chunk
$data = str_repeat('x', $chunk_size);
# repeatedly write chunk
foreach (range(0, $num_chunks - 1) as $i) {
$e->write($data);
}
});
}, function($zip_path) use ($expected_size) {
$zip = $this->open_archive($zip_path);
$st = $zip->statName('hello.txt');
$this->assertEquals($expected_size, $st['size']);
});
}
};
|