xref: /PHP-8.0/ext/zip/tests/oo_namelocate.phpt (revision f8d79582)
1--TEST--
2Locate entries by name
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip');
6?>
7--FILE--
8<?php
9$dirname = __DIR__ . '/';
10include $dirname . 'utils.inc';
11$file = $dirname . 'oo_namelocate.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--CLEAN--
47<?php
48unlink(__DIR__ . '/oo_namelocate.zip');
49?>
50