xref: /PHP-5.6/ext/zip/tests/oo_namelocate.phpt (revision 9d0f6426)
1--TEST--
2Locate entries by name
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->locateName('entry1.txt'));
36var_dump($zip->locateName('eNtry2.txt'));
37var_dump($zip->locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE));
38var_dump($zip->locateName('enTRy2d.txt', ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR));
39$zip->close();
40
41?>
42--EXPECTF--
43int(0)
44bool(false)
45int(1)
46int(2)
47