xref: /PHP-8.2/ext/zip/tests/oo_progress.phpt (revision 74859783)
1--TEST--
2registerProgressCallback
3--EXTENSIONS--
4zip
5--SKIPIF--
6<?php
7/* $Id$ */
8if (!method_exists('ZipArchive', 'registerProgressCallback')) die('skip libzip too old');
9?>
10--INI--
11date.timezone=UTC
12--FILE--
13<?php
14$dirname = dirname(__FILE__) . '/';
15$file = $dirname . '__tmp_oo_progress.zip';
16
17@unlink($file);
18
19$zip = new ZipArchive;
20if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
21    exit('failed');
22}
23
24var_dump($zip->registerProgressCallback(0.5, function ($r) {
25    // Only check start/end as intermediate is not reliable
26    if ($r == 0.0) echo "start\n";
27    if ($r == 1.0) echo "end\n";
28}));
29var_dump($zip->addFromString('foo', 'entry #1'));
30
31var_dump($zip->close());
32unlink($file);
33?>
34Done
35--EXPECT--
36bool(true)
37bool(true)
38start
39end
40bool(true)
41Done
42