Annotation of embedaddon/php/ext/standard/tests/strings/wordwrap_variation4.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test wordwrap() function : usage variations  - unexptected value for cut argument
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string wordwrap ( string $str [, int $width [, string $break [, bool $cut]]] )
                      6:  * Description: Wraps buffer to selected number of characters using string break char
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11:  * test wordwrap() by supplying different values for cut argument
                     12: */
                     13: 
                     14: echo "*** Testing wordwrap() : usage variations ***\n";
                     15: // initialize all required variables
                     16: $str = 'testing wordwrap function';
                     17: $width = 10;
                     18: $break = '<br />\n';
                     19: 
                     20: // get an unset variable
                     21: $unset_var = true;
                     22: unset($unset_var);
                     23: 
                     24: // resource variable
                     25: $fp = fopen(__FILE__, "r");
                     26: 
                     27: // array with different values
                     28: $values =  array (
                     29: 
                     30:   // integer values
                     31:   0,
                     32:   1,
                     33:   12345,
                     34:   -2345,
                     35: 
                     36:   // float values
                     37:   10.5,
                     38:   -10.5,
                     39:   10.5e10,
                     40:   10.6E-10,
                     41:   .5,
                     42: 
                     43:   // array values
                     44:   array(),
                     45:   array(0),
                     46:   array(1),
                     47:   array(1, 2),
                     48:   array('color' => 'red', 'item' => 'pen'),
                     49: 
                     50:   // string values
                     51:   "string",
                     52:   'string',
                     53: 
                     54:   // objects
                     55:   new stdclass(),
                     56: 
                     57:   // empty string
                     58:   "",
                     59:   '',
                     60: 
                     61:   // undefined variable
                     62:   @$undefined_var,
                     63: 
                     64:   // unset variable
                     65:   @$unset_var
                     66: );
                     67: 
                     68: // loop though each element of the array and check the working of wordwrap()
1.1.1.2 ! misho      69: // when $cut argument is supplied with different values
1.1       misho      70: echo "\n--- Testing wordwrap() by supplying different values for 'cut' argument ---\n";
                     71: $counter = 1;
                     72: for($index = 0; $index < count($values); $index ++) {
                     73:   echo "-- Iteration $counter --\n";
                     74:   $cut = $values [$index];
                     75: 
                     76:   var_dump( wordwrap($str, $width, $break, $cut) );
                     77: 
                     78:   $counter ++;
                     79: }
                     80: 
                     81: // close the resource
                     82: fclose($fp);
                     83: 
                     84: echo "Done\n";
                     85: ?>
                     86: --EXPECTF--
                     87: *** Testing wordwrap() : usage variations ***
                     88: 
                     89: --- Testing wordwrap() by supplying different values for 'cut' argument ---
                     90: -- Iteration 1 --
                     91: string(39) "testing<br />\nwordwrap<br />\nfunction"
                     92: -- Iteration 2 --
                     93: string(39) "testing<br />\nwordwrap<br />\nfunction"
                     94: -- Iteration 3 --
                     95: string(39) "testing<br />\nwordwrap<br />\nfunction"
                     96: -- Iteration 4 --
                     97: string(39) "testing<br />\nwordwrap<br />\nfunction"
                     98: -- Iteration 5 --
                     99: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    100: -- Iteration 6 --
                    101: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    102: -- Iteration 7 --
                    103: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    104: -- Iteration 8 --
                    105: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    106: -- Iteration 9 --
                    107: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    108: -- Iteration 10 --
                    109: 
                    110: Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
                    111: NULL
                    112: -- Iteration 11 --
                    113: 
                    114: Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
                    115: NULL
                    116: -- Iteration 12 --
                    117: 
                    118: Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
                    119: NULL
                    120: -- Iteration 13 --
                    121: 
                    122: Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
                    123: NULL
                    124: -- Iteration 14 --
                    125: 
                    126: Warning: wordwrap() expects parameter 4 to be boolean, array given in %s on line %d
                    127: NULL
                    128: -- Iteration 15 --
                    129: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    130: -- Iteration 16 --
                    131: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    132: -- Iteration 17 --
                    133: 
                    134: Warning: wordwrap() expects parameter 4 to be boolean, object given in %s on line %d
                    135: NULL
                    136: -- Iteration 18 --
                    137: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    138: -- Iteration 19 --
                    139: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    140: -- Iteration 20 --
                    141: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    142: -- Iteration 21 --
                    143: string(39) "testing<br />\nwordwrap<br />\nfunction"
                    144: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>