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