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