xref: /PHP-7.4/ext/zip/tests/oo_unchangeName.phpt (revision 1eae7722)
1--TEST--
2Test basic ZipArchive::unchangeName() method
3--CREDITS--
4PHP TestFest 2017 - Bergfreunde, Florian Engelhardt
5--SKIPIF--
6<?php if (!extension_loaded("zip")) print "skip"; ?>
7--FILE--
8<?php
9$dirname = __DIR__ . '/';
10$file = $dirname . 'oo_unchangeName.zip';
11copy($dirname.'test.zip', $file);
12
13var_dump(md5_file($file));
14
15$zip = new ZipArchive();
16$zip->open($file);
17var_dump($zip->getNameIndex(0));
18var_dump($zip->getCommentIndex(0));
19
20$zip->renameIndex(0, 'baz filename');
21$zip->setCommentIndex(0, 'baz comment');
22
23var_dump($zip->getNameIndex(0));
24var_dump($zip->getCommentIndex(0));
25
26$zip->unchangeName('baz filename');
27
28var_dump($zip->getNameIndex(0));
29var_dump($zip->getCommentIndex(0));
30
31$zip->close();
32
33var_dump(md5_file($file));
34?>
35--CLEAN--
36<?php
37unlink(__DIR__.'/oo_unchangeName.zip');
38?>
39--EXPECT--
40string(32) "cb753d0a812b2edb386bdcbc4cd7d131"
41string(3) "bar"
42string(0) ""
43string(12) "baz filename"
44string(11) "baz comment"
45string(3) "bar"
46string(0) ""
47string(32) "cb753d0a812b2edb386bdcbc4cd7d131"
48