1--TEST-- 2ziparchive::addFile() function 3--EXTENSIONS-- 4zip 5--FILE-- 6<?php 7 8$dirname = __DIR__ . '/'; 9include $dirname . 'utils.inc'; 10$file = $dirname . 'oo_addfile.zip'; 11 12copy($dirname . 'test.zip', $file); 13 14$zip = new ZipArchive; 15if (!$zip->open($file)) { 16 exit('failed'); 17} 18var_dump($zip->lastId); 19if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) { 20 echo "failed\n"; 21} 22var_dump($zip->lastId); 23if (!$zip->addFile($dirname . 'utils.inc', 'mini.txt', 12, 34)) { 24 echo "failed\n"; 25} 26var_dump($zip->lastId); 27if ($zip->status == ZIPARCHIVE::ER_OK) { 28 if (!verify_entries($zip, [ 29 "bar", 30 "foobar/", 31 "foobar/baz", 32 "entry1.txt", 33 "test.php", 34 "mini.txt" 35 ])) { 36 echo "failed\n"; 37 } else { 38 echo "OK\n"; 39 } 40 $zip->close(); 41} else { 42 echo "failed\n"; 43} 44if (!$zip->open($file)) { 45 exit('failed'); 46} 47var_dump(strlen($zip->getFromName('test.php')) == filesize($dirname . 'utils.inc')); 48var_dump(strlen($zip->getFromName('mini.txt')) == 34); 49@unlink($file); 50?> 51--EXPECT-- 52int(-1) 53int(4) 54int(5) 55OK 56bool(true) 57bool(true) 58