Annotation of embedaddon/php/ext/standard/tests/strings/strip_tags_variation1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test strip_tags() function : usage variations - unexpected values for 'str' argument
                      3: --INI--
                      4: set short_open_tag = on
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : string strip_tags(string $str [, string $allowable_tags])
                      8:  * Description: Strips HTML and PHP tags from a string 
                      9:  * Source code: ext/standard/string.c
                     10: */
                     11: 
                     12: /*
                     13:  * testing functionality of strip_tags() by giving unexpected input values for $str argument
                     14: */
                     15: 
                     16: echo "*** Testing strip_tags() : usage variations ***\n";
                     17: 
                     18: //get an unset variable
                     19: $unset_var = 10;
                     20: unset ($unset_var);
                     21: 
                     22: //get a resource variable
                     23: $fp = fopen(__FILE__, "r");
                     24: 
                     25: //get a class
                     26: class classA{
                     27:   public function __toString(){
                     28:     return "Class A object";
                     29:   }
                     30: }
                     31: 
                     32: //array of values to iterate over
                     33: $values = array(
                     34: 
                     35:              // int data
                     36: /*1*/     0,
                     37:              1,
                     38:              12345,
                     39:              -2345,
                     40:        
                     41:              // float data
                     42: /*5*/      10.5,
                     43:              -10.5,
                     44:              10.1234567e10,
                     45:              10.7654321E-10,
                     46:              .5,
                     47:        
                     48:              // array data
                     49: /*10*/    array(),
                     50:              array(0),
                     51:              array(1),
                     52:              array(1, 2),
                     53:              array('color' => 'red', 'item' => 'pen'),
                     54:        
                     55:              // null data
                     56: /*15*/    NULL,
                     57:              null,
                     58:        
                     59:              // boolean data
                     60: /*17*/    true,
                     61:              false,
                     62:              TRUE,
                     63:              FALSE,
                     64:        
                     65:              // empty data
                     66: /*21*/    "",
                     67:              '',
                     68:        
                     69:              // object data
                     70: /*23*/    new classA(),
                     71:        
                     72:              // undefined data
                     73: /*24*/    @$undefined_var,
                     74:        
                     75:              // unset data
                     76: /*25*/    @$unset_var,
                     77:        
                     78:              // resource variable
                     79: /*26*/    $fp
                     80: 
                     81: );
                     82: 
                     83: // loop through each element of the array for allowable_tags
                     84: $iterator = 1;
                     85: foreach($values as $value) {
                     86:       echo "-- Iteration $iterator --\n";
                     87:       var_dump( strip_tags($value) );
                     88:       $iterator++;
                     89: };
                     90: 
                     91: ?>
                     92: ===DONE===
                     93: --EXPECTF--
                     94: *** Testing strip_tags() : usage variations ***
                     95: -- Iteration 1 --
                     96: string(1) "0"
                     97: -- Iteration 2 --
                     98: string(1) "1"
                     99: -- Iteration 3 --
                    100: string(5) "12345"
                    101: -- Iteration 4 --
                    102: string(5) "-2345"
                    103: -- Iteration 5 --
                    104: string(4) "10.5"
                    105: -- Iteration 6 --
                    106: string(5) "-10.5"
                    107: -- Iteration 7 --
                    108: string(12) "101234567000"
                    109: -- Iteration 8 --
                    110: string(13) "1.07654321E-9"
                    111: -- Iteration 9 --
                    112: string(3) "0.5"
                    113: -- Iteration 10 --
                    114: 
                    115: Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
                    116: NULL
                    117: -- Iteration 11 --
                    118: 
                    119: Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
                    120: NULL
                    121: -- Iteration 12 --
                    122: 
                    123: Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
                    124: NULL
                    125: -- Iteration 13 --
                    126: 
                    127: Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
                    128: NULL
                    129: -- Iteration 14 --
                    130: 
                    131: Warning: strip_tags() expects parameter 1 to be string, array given in %s on line %d
                    132: NULL
                    133: -- Iteration 15 --
                    134: string(0) ""
                    135: -- Iteration 16 --
                    136: string(0) ""
                    137: -- Iteration 17 --
                    138: string(1) "1"
                    139: -- Iteration 18 --
                    140: string(0) ""
                    141: -- Iteration 19 --
                    142: string(1) "1"
                    143: -- Iteration 20 --
                    144: string(0) ""
                    145: -- Iteration 21 --
                    146: string(0) ""
                    147: -- Iteration 22 --
                    148: string(0) ""
                    149: -- Iteration 23 --
                    150: string(14) "Class A object"
                    151: -- Iteration 24 --
                    152: string(0) ""
                    153: -- Iteration 25 --
                    154: string(0) ""
                    155: -- Iteration 26 --
                    156: 
                    157: Warning: strip_tags() expects parameter 1 to be string, resource given in %s on line %d
                    158: NULL
                    159: ===DONE===

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