summaryrefslogtreecommitdiff
path: root/ext/zip/tests/oo_addfile.phpt
blob: 254f2b762073ac8cdedfd9f636e4340cd4814adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
ziparchive::addFile() function
--SKIPIF--
<?php
if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php

$dirname = __DIR__ . '/';
include $dirname . 'utils.inc';
$file = $dirname . 'oo_addfile.zip';

copy($dirname . 'test.zip', $file);

$zip = new ZipArchive;
if (!$zip->open($file)) {
	exit('failed');
}
if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) {
	echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
	if (!verify_entries($zip, [
		"bar",
		"foobar/",
		"foobar/baz",
		"entry1.txt",
		"test.php"
	])) {
		echo "failed\n";
	} else {
		echo "OK";
	}
	$zip->close();
} else {
	echo "failed\n";
}
@unlink($file);
?>
--EXPECT--
OK