xref: /PHP-8.0/ext/zip/tests/oo_supported.phpt (revision 682e2f6c)
1--TEST--
2ziparchive::properties isset()/empty() checks
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7if (!method_exists('ZipArchive', 'isCompressionMethodSupported')) die('skip needs libzip >= 1.7');
8?>
9--FILE--
10<?php
11$methods = [
12    ZipArchive::CM_STORE      => "STORE",
13    ZipArchive::CM_DEFLATE    => "DEFLATE",
14    ZipArchive::CM_BZIP2      => "BZIP2",
15    ZipArchive::CM_XZ         => "XZ",
16];
17foreach($methods as $method => $name) {
18    echo "Compression $name\n";
19    var_dump(ZipArchive::isCompressionMethodSupported($method));
20    var_dump(ZipArchive::isCompressionMethodSupported($method, false));
21}
22
23$methods = [
24    ZipArchive::EM_NONE        => "NONE",
25    ZipArchive::EM_TRAD_PKWARE => "TRAD_PKWARE",
26    ZipArchive::EM_AES_128     => "AES-128",
27    ZipArchive::EM_AES_192     => "AES-192",
28    ZipArchive::EM_AES_256     => "AES-256",
29];
30foreach($methods as $method => $name) {
31    echo "Encryption $name\n";
32    var_dump(ZipArchive::isEncryptionMethodSupported($method));
33    var_dump(ZipArchive::isEncryptionMethodSupported($method, false));
34}
35?>
36Done
37--EXPECTF--
38Compression STORE
39bool(true)
40bool(true)
41Compression DEFLATE
42bool(true)
43bool(true)
44Compression BZIP2
45bool(%s)
46bool(%s)
47Compression XZ
48bool(%s)
49bool(%s)
50Encryption NONE
51bool(true)
52bool(true)
53Encryption TRAD_PKWARE
54bool(true)
55bool(true)
56Encryption AES-128
57bool(%s)
58bool(%s)
59Encryption AES-192
60bool(%s)
61bool(%s)
62Encryption AES-256
63bool(%s)
64bool(%s)
65Done
66