xref: /PHP-7.3/ext/zip/tests/oo_getnameindex.phpt (revision 0eabd523)
1--TEST--
2getNameIndex
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip');
6?>
7--FILE--
8<?php
9$dirname = dirname(__FILE__) . '/';
10include $dirname . 'utils.inc';
11$file = $dirname . '__tmp_oo_rename.zip';
12
13@unlink($file);
14
15$zip = new ZipArchive;
16if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
17	exit('failed');
18}
19
20$zip->addFromString('entry1.txt', 'entry #1');
21$zip->addFromString('entry2.txt', 'entry #2');
22$zip->addFromString('dir/entry2d.txt', 'entry #2');
23
24if (!$zip->status == ZIPARCHIVE::ER_OK) {
25	echo "failed to write zip\n";
26}
27$zip->close();
28
29if (!$zip->open($file)) {
30	exit('failed');
31}
32
33
34var_dump($zip->getNameIndex(0));
35var_dump($zip->getNameIndex(1));
36var_dump($zip->getNameIndex(2));
37var_dump($zip->getNameIndex(3));
38
39$zip->close();
40
41?>
42--EXPECT--
43string(10) "entry1.txt"
44string(10) "entry2.txt"
45string(15) "dir/entry2d.txt"
46bool(false)
47