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