xref: /PHP-8.2/ext/zip/tests/oo_unchangeIndex.phpt (revision 74859783)
1--TEST--
2Test basic ZipArchive::unchangeIndex() Method
3--CREDITS--
4PHP TestFest 2017 - Bergfreunde, Florian Engelhardt
5--EXTENSIONS--
6zip
7--FILE--
8<?php
9$dirname = __DIR__ . '/';
10$file = $dirname . 'oo_unchangeIndex.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->unchangeIndex(0);
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_unchangeIndex.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