Skip to content

Commit

Permalink
Added basic test for ZipArchive::unchangeIndex()
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl authored and petk committed Feb 9, 2019
1 parent 2ca3bec commit ec814c3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ext/zip/tests/oo_unchangeIndex.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
Test basic ZipArchive::unchangeIndex() Method
--CREDITS--
PHP TestFest 2017 - Bergfreunde, Florian Engelhardt
--SKIPIF--
<?php if (!extension_loaded("zip")) print "skip"; ?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
$file = $dirname . '__tmp_oo_unchangeIndex.zip';
copy($dirname.'test.zip', $file);

var_dump(md5_file($file));

$zip = new ZipArchive();
$zip->open($file);
var_dump($zip->getNameIndex(0));
var_dump($zip->getCommentIndex(0));

$zip->renameIndex(0, 'baz filename');
$zip->setCommentIndex(0, 'baz comment');

var_dump($zip->getNameIndex(0));
var_dump($zip->getCommentIndex(0));

$zip->unchangeIndex(0);

var_dump($zip->getNameIndex(0));
var_dump($zip->getCommentIndex(0));

var_dump(md5_file($file));

unlink($file);
?>
--EXPECT--
string(32) "cb753d0a812b2edb386bdcbc4cd7d131"
string(3) "bar"
string(0) ""
string(12) "baz filename"
string(11) "baz comment"
string(3) "bar"
string(0) ""
string(32) "cb753d0a812b2edb386bdcbc4cd7d131"

0 comments on commit ec814c3

Please sign in to comment.