xref: /php-src/ext/zip/tests/oo_addfile_proc.phpt (revision 57123ee4)
1--TEST--
2ziparchive::addFile() for dynamic files reported empty
3--EXTENSIONS--
4zip
5--SKIPIF--
6<?php
7if (!file_exists('/proc/cpuinfo')) die('skip no /proc');
8if (!defined('ZipArchive::LENGTH_UNCHECKED')) die('skip libzip too old');
9?>
10--FILE--
11<?php
12
13include __DIR__ . '/utils.inc';
14$file = __DIR__ . '/__tmp_oo_addfile_proc.zip';
15
16$zip = new ZipArchive;
17if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
18	exit('failed');
19}
20if (!$zip->addFile('/proc/cpuinfo', 'cpu.txt', 0, ZipArchive::LENGTH_UNCHECKED)) {
21	echo "failed\n";
22}
23if (!$zip->addFile('/proc/meminfo', 'mem.txt', 0, ZipArchive::LENGTH_UNCHECKED)) {
24	echo "failed\n";
25}
26
27if ($zip->status == ZIPARCHIVE::ER_OK) {
28	dump_entries_name($zip);
29	$zip->close();
30} else {
31	echo "failed\n";
32}
33var_dump($zip->status);
34
35if (!$zip->open($file)) {
36	exit('failed');
37}
38var_dump(strlen($zip->getFromName('cpu.txt')) > 0);
39var_dump(strlen($zip->getFromName('mem.txt')) > 0);
40
41@unlink($file);
42?>
43Done
44--EXPECTF--
450 cpu.txt
461 mem.txt
47int(0)
48bool(true)
49bool(true)
50Done
51