1--TEST--
2setComment error behavior
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip zip extension not available');
6?>
7--FILE--
8<?php
9$file = __DIR__ . '/__tmp_oo_set_comment_error.zip';
10
11@unlink($file);
12
13$zip = new ZipArchive;
14if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
15    exit('failed');
16}
17
18$zip->addFromString('entry1.txt', 'entry #1');
19$zip->addFromString('entry2.txt', 'entry #2');
20
21$longComment = str_repeat('a', 0x10000);
22
23try {
24    var_dump($zip->setArchiveComment($longComment));
25} catch (\ValueError $e) {
26    echo $e->getMessage() . \PHP_EOL;
27}
28try {
29    var_dump($zip->setCommentName('entry1.txt', $longComment));
30} catch (\ValueError $e) {
31    echo $e->getMessage() . \PHP_EOL;
32}
33try {
34    var_dump($zip->setCommentIndex(1, $longComment));
35} catch (\ValueError $e) {
36    echo $e->getMessage() . \PHP_EOL;
37}
38
39$zip->close();
40?>
41--EXPECT--
42ZipArchive::setArchiveComment(): Argument #1 ($comment) must be less than 65535 bytes
43ZipArchive::setCommentName(): Argument #2 ($comment) must be less than 65535 bytes
44ZipArchive::setCommentIndex(): Argument #2 ($comment) must be less than 65535 bytes
45--CLEAN--
46<?php
47@unlink(__DIR__ . '/__tmp_oo_set_comment_error.zip');
48?>
49