-
Notifications
You must be signed in to change notification settings - Fork 20
/
079.phpt
65 lines (50 loc) · 1.31 KB
/
079.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--TEST--
RarArchive count elements handler test
--SKIPIF--
<?php if(!extension_loaded("rar")) print "skip"; ?>
--FILE--
<?php
$f = dirname(__FILE__) . "/dirs_and_extra_headers.rar";
$fempty = dirname(__FILE__) . "/garbage.part03.rar";
echo "* Normal test:\n";
$a = RarArchive::open($f);
echo "Count: " . count($a) . "\n";
echo "\n* Closed file test (1):\n";
$a = RarArchive::open($f);
$a->close();
var_dump(count($a));
echo "\n* Closed file test (2):\n";
$a = RarArchive::open($f);
$a->getEntries();
$a->close();
var_dump(count($a));
echo "\n* Closed file test (3, exceptions):\n";
$a = RarArchive::open($f);
RarException::setUsingExceptions(true);
$a->getEntries();
$a->close();
try {
var_dump(count($a));
} catch (RarException $e) {
echo "OK, threw exception with message \"".$e->getMessage()."\"\n";
}
RarException::setUsingExceptions(false);
echo "\n* Empty file:\n";
$a = RarArchive::open($fempty);
echo "Count: " . count($a) . "\n";
echo "\n";
echo "Done.\n";
--EXPECTF--
* Normal test:
Count: 13
* Closed file test (1):
Warning: count(): The archive is already closed in %s on line %d
int(0)
* Closed file test (2):
Warning: count(): The archive is already closed in %s on line %d
int(0)
* Closed file test (3, exceptions):
OK, threw exception with message "The archive is already closed"
* Empty file:
Count: 0
Done.