xref: /PHP-7.2/ext/zip/tests/oo_rename.phpt (revision 9d0f6426)
1--TEST--
2Rename entries
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10$dirname = dirname(__FILE__) . '/';
11include $dirname . 'utils.inc';
12$file = $dirname . '__tmp_oo_rename.zip';
13
14@unlink($file);
15
16$zip = new ZipArchive;
17if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
18	exit('failed');
19}
20
21$zip->addFromString('entry1.txt', 'entry #1');
22$zip->addFromString('entry2.txt', 'entry #2');
23$zip->addFromString('dir/entry2.txt', 'entry #2');
24
25if (!$zip->status == ZIPARCHIVE::ER_OK) {
26	var_dump($zip);
27	echo "failed\n";
28}
29
30$zip->close();
31
32if (!$zip->open($file)) {
33	exit('failed');
34}
35
36dump_entries_name($zip);
37echo "\n";
38
39if (!$zip->renameIndex(0, 'ren_entry1.txt')) {
40	echo "failed index 0\n";
41}
42
43if (!$zip->renameName('dir/entry2.txt', 'dir3/ren_entry2.txt')) {
44	echo "failed name dir/entry2.txt\n";
45}
46dump_entries_name($zip);
47$zip->close();
48
49@unlink($file);
50?>
51--EXPECTF--
520 entry1.txt
531 entry2.txt
542 dir/entry2.txt
55
560 ren_entry1.txt
571 entry2.txt
582 dir3/ren_entry2.txt
59