Skip to content

Commit 1227284

Browse files
realFlowControlpetk
authored andcommitted
Added basic test for ZipArchive::unchangeName()
1 parent ec814c3 commit 1227284

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

ext/zip/tests/oo_unchangeName.phpt

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

0 commit comments

Comments
 (0)