1--TEST--
2Test wordwrap() function : error conditions
3--FILE--
4<?php
5echo "*** Testing wordwrap() : error conditions ***\n";
6
7$str = 'testing wordwrap function';
8$width = 10;
9$break = '<br />\n';
10$cut = true;
11
12// $width arg as negative value
13echo "\n-- Testing wordwrap() function with negative/zero value for width argument --\n";
14echo "-- width = 0 & cut = false --\n";
15// width as zero and cut as false
16$width = 0;
17$cut = false;
18var_dump( wordwrap($str, $width, $break, $cut) );
19
20echo "-- width = 0 & cut = true --\n";
21// width as zero and cut as true
22$width = 0;
23$cut = true;
24
25try {
26    wordwrap($str, $width, $break, $cut);
27} catch (\ValueError $e) {
28    echo $e->getMessage() . "\n";
29}
30
31echo "-- width = -10 & cut = false --\n";
32// width as -ne and cut as false
33$width = -10;
34$cut = false;
35var_dump( wordwrap($str, $width, $break, $cut) );
36
37echo "-- width = -10 & cut = true --\n";
38// width as -ne and cut as true
39$width = -10;
40$cut = true;
41var_dump( wordwrap($str, $width, $break, $cut) );
42?>
43--EXPECT--
44*** Testing wordwrap() : error conditions ***
45
46-- Testing wordwrap() function with negative/zero value for width argument --
47-- width = 0 & cut = false --
48string(39) "testing<br />\nwordwrap<br />\nfunction"
49-- width = 0 & cut = true --
50wordwrap(): Argument #4 ($cut_long_words) cannot be true when argument #2 ($width) is 0
51-- width = -10 & cut = false --
52string(39) "testing<br />\nwordwrap<br />\nfunction"
53-- width = -10 & cut = true --
54string(223) "<br />\nt<br />\ne<br />\ns<br />\nt<br />\ni<br />\nn<br />\ng<br />\n<br />\nw<br />\no<br />\nr<br />\nd<br />\nw<br />\nr<br />\na<br />\np<br />\n<br />\nf<br />\nu<br />\nn<br />\nc<br />\nt<br />\ni<br />\no<br />\nn"
55