Annotation of embedaddon/php/ext/standard/tests/strings/strtr_variation9.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test strtr() function : usage variations - unexpected inputs for all arguments
        !             3: --FILE--
        !             4: <?php
        !             5: /* Prototype  : string strtr(string $str, string $from[, string $to]);
        !             6:                 string strtr(string $str, array $replace_pairs);
        !             7:  * Description: Translates characters in str using given translation tables
        !             8:  * Source code: ext/standard/string.c
        !             9: */
        !            10: 
        !            11: /* Test strtr() function: with unexpected inputs for 'str', 'from', 'to' & 'replace_pairs' arguments */
        !            12: 
        !            13: echo "*** Testing strtr() function: with unexpected inputs for all arguments ***\n";
        !            14: 
        !            15: //get an unset variable
        !            16: $unset_var = 'string_val';
        !            17: unset($unset_var);
        !            18: 
        !            19: //defining a class
        !            20: class sample  {
        !            21:   public function __toString() {
        !            22:     return "sample object";
        !            23:   } 
        !            24: }
        !            25: 
        !            26: //getting the resource
        !            27: $file_handle = fopen(__FILE__, "r");
        !            28: 
        !            29: // array with different values
        !            30: $values =  array (
        !            31: 
        !            32:                  // integer values
        !            33: /*1*/    0,
        !            34:                  1,
        !            35:                  -2,
        !            36:                
        !            37:                  // float values
        !            38: /*4*/    10.5,
        !            39:                  -20.5,
        !            40:                  10.1234567e10,
        !            41:                
        !            42:                  // array values
        !            43: /*7*/    array(),
        !            44:                  array(0),
        !            45:                  array(1),
        !            46:                  array(1, 2),
        !            47:                  array('color' => 'red', 'item' => 'pen'),
        !            48:                
        !            49:                  // boolean values
        !            50: /*12*/   true,
        !            51:                  false,
        !            52:                  TRUE,
        !            53:                  FALSE,
        !            54:                
        !            55:                  // null vlaues
        !            56: /*16*/   NULL,
        !            57:                  null,
        !            58:                
        !            59:                  // objects
        !            60: /*18*/   new sample(),
        !            61:                
        !            62:                  // resource
        !            63: /*19*/   $file_handle,
        !            64:                
        !            65:                  // undefined variable
        !            66: /*20*/   @$undefined_var,
        !            67:                
        !            68:                  // unset variable
        !            69: /*21*/   @$unset_var
        !            70: );
        !            71: 
        !            72: // loop through with each element of the $values array to test strtr() function
        !            73: $count = 1;
        !            74: for($index = 0; $index < count($values); $index++) {
        !            75:   echo "\n-- Iteration $count --\n";
        !            76:   var_dump( strtr($values[$index], $values[$index], $values[$index]) ); //fn call with three args
        !            77:   var_dump( strtr($values[$index], $values[$index]) );  //fn call with two args
        !            78:   $count ++;
        !            79: }
        !            80: 
        !            81: fclose($file_handle);  //closing the file handle
        !            82: 
        !            83: ?>
        !            84: ===DONE===
        !            85: --EXPECTF--
        !            86: *** Testing strtr() function: with unexpected inputs for all arguments ***
        !            87: 
        !            88: -- Iteration 1 --
        !            89: string(1) "0"
        !            90: 
        !            91: Warning: strtr(): The second argument is not an array in %s on line %d
        !            92: bool(false)
        !            93: 
        !            94: -- Iteration 2 --
        !            95: string(1) "1"
        !            96: 
        !            97: Warning: strtr(): The second argument is not an array in %s on line %d
        !            98: bool(false)
        !            99: 
        !           100: -- Iteration 3 --
        !           101: string(2) "-2"
        !           102: 
        !           103: Warning: strtr(): The second argument is not an array in %s on line %d
        !           104: bool(false)
        !           105: 
        !           106: -- Iteration 4 --
        !           107: string(4) "10.5"
        !           108: 
        !           109: Warning: strtr(): The second argument is not an array in %s on line %d
        !           110: bool(false)
        !           111: 
        !           112: -- Iteration 5 --
        !           113: string(5) "-20.5"
        !           114: 
        !           115: Warning: strtr(): The second argument is not an array in %s on line %d
        !           116: bool(false)
        !           117: 
        !           118: -- Iteration 6 --
        !           119: string(12) "101234567000"
        !           120: 
        !           121: Warning: strtr(): The second argument is not an array in %s on line %d
        !           122: bool(false)
        !           123: 
        !           124: -- Iteration 7 --
        !           125: 
        !           126: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           127: NULL
        !           128: 
        !           129: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           130: NULL
        !           131: 
        !           132: -- Iteration 8 --
        !           133: 
        !           134: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           135: NULL
        !           136: 
        !           137: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           138: NULL
        !           139: 
        !           140: -- Iteration 9 --
        !           141: 
        !           142: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           143: NULL
        !           144: 
        !           145: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           146: NULL
        !           147: 
        !           148: -- Iteration 10 --
        !           149: 
        !           150: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           151: NULL
        !           152: 
        !           153: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           154: NULL
        !           155: 
        !           156: -- Iteration 11 --
        !           157: 
        !           158: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           159: NULL
        !           160: 
        !           161: Warning: strtr() expects parameter 1 to be string, array given in %s on line %d
        !           162: NULL
        !           163: 
        !           164: -- Iteration 12 --
        !           165: string(1) "1"
        !           166: 
        !           167: Warning: strtr(): The second argument is not an array in %s on line %d
        !           168: bool(false)
        !           169: 
        !           170: -- Iteration 13 --
        !           171: string(0) ""
        !           172: 
        !           173: Warning: strtr(): The second argument is not an array in %s on line %d
        !           174: bool(false)
        !           175: 
        !           176: -- Iteration 14 --
        !           177: string(1) "1"
        !           178: 
        !           179: Warning: strtr(): The second argument is not an array in %s on line %d
        !           180: bool(false)
        !           181: 
        !           182: -- Iteration 15 --
        !           183: string(0) ""
        !           184: 
        !           185: Warning: strtr(): The second argument is not an array in %s on line %d
        !           186: bool(false)
        !           187: 
        !           188: -- Iteration 16 --
        !           189: string(0) ""
        !           190: 
        !           191: Warning: strtr(): The second argument is not an array in %s on line %d
        !           192: bool(false)
        !           193: 
        !           194: -- Iteration 17 --
        !           195: string(0) ""
        !           196: 
        !           197: Warning: strtr(): The second argument is not an array in %s on line %d
        !           198: bool(false)
        !           199: 
        !           200: -- Iteration 18 --
        !           201: string(13) "sample object"
        !           202: 
        !           203: Warning: strtr(): The second argument is not an array in %s on line %d
        !           204: bool(false)
        !           205: 
        !           206: -- Iteration 19 --
        !           207: 
        !           208: Warning: strtr() expects parameter 1 to be string, resource given in %s on line %d
        !           209: NULL
        !           210: 
        !           211: Warning: strtr() expects parameter 1 to be string, resource given in %s on line %d
        !           212: NULL
        !           213: 
        !           214: -- Iteration 20 --
        !           215: string(0) ""
        !           216: 
        !           217: Warning: strtr(): The second argument is not an array in %s on line %d
        !           218: bool(false)
        !           219: 
        !           220: -- Iteration 21 --
        !           221: string(0) ""
        !           222: 
        !           223: Warning: strtr(): The second argument is not an array in %s on line %d
        !           224: bool(false)
        !           225: ===DONE===

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