1--TEST-- 2ziparchive::addFromString and FL_OVERWRITE 3--EXTENSIONS-- 4zip 5--SKIPIF-- 6<?php 7/* $Id$ */ 8?> 9--FILE-- 10<?php 11 12include __DIR__ . '/utils.inc'; 13$dirname = __DIR__ . '/oo_add_from_string_dir/'; 14$file = $dirname . 'tmp.zip'; 15 16@mkdir($dirname); 17copy(__DIR__ . '/test.zip', $file); 18 19$zip = new ZipArchive(); 20if (!$zip->open($file)) { 21 exit('failed'); 22} 23 24// New file 25var_dump($zip->addFromString('bar', __FILE__)); 26var_dump($zip->status == ZipArchive::ER_OK); 27// Fails to add existing file 28var_dump($zip->addFromString('entry1.txt', __FILE__, 0)); 29var_dump($zip->status == ZipArchive::ER_EXISTS); 30// Overwrite 31var_dump($zip->addFromString('entry1.txt', __FILE__, ZipArchive::FL_OVERWRITE)); 32var_dump($zip->status == ZipArchive::ER_OK); 33 34if ($zip->status == ZipArchive::ER_OK) { 35 dump_entries_name($zip); 36 $zip->close(); 37} else { 38 echo "failed\n"; 39} 40?> 41Done 42--CLEAN-- 43<?php 44$dirname = __DIR__ . '/oo_add_from_string_dir/'; 45unlink($dirname . 'tmp.zip'); 46rmdir($dirname); 47?> 48--EXPECT-- 49bool(true) 50bool(true) 51bool(false) 52bool(true) 53bool(true) 54bool(true) 550 bar 561 foobar/ 572 foobar/baz 583 entry1.txt 59Done 60