Annotation of embedaddon/php/ext/date/tests/gmstrftime_variation1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test gmstrftime() function : usage variation - Passing unexpected values to first argument 'format'.
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string gmstrftime(string format [, int timestamp])
                      6:  * Description: Format a GMT/UCT time/date according to locale settings 
                      7:  * Source code: ext/date/php_date.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: echo "*** Testing gmstrftime() : usage variation ***\n";
                     12: 
                     13: // Initialise function arguments not being substituted (if any)
                     14: $timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
                     15: 
                     16: //get an unset variable
                     17: $unset_var = 10;
                     18: unset ($unset_var);
                     19: 
                     20: // define some classes
                     21: class classWithToString
                     22: {
                     23:        public function __toString() {
                     24:                return "Class A object";
                     25:        }
                     26: }
                     27: 
                     28: class classWithoutToString
                     29: {
                     30: }
                     31: 
                     32: // heredoc string
                     33: $heredoc = <<<EOT
                     34: hello world
                     35: EOT;
                     36: 
                     37: // add arrays
                     38: $index_array = array (1, 2, 3);
                     39: $assoc_array = array ('one' => 1, 'two' => 2);
                     40: 
                     41: //array of values to iterate over
                     42: $inputs = array(
                     43: 
                     44:       // int data
                     45:       'int 0' => 0,
                     46:       'int 1' => 1,
                     47:       'int 12345' => 12345,
                     48:       'int -12345' => -12345,
                     49: 
                     50:       // float data
                     51:       'float 10.5' => 10.5,
                     52:       'float -10.5' => -10.5,
                     53:       'float 12.3456789000e10' => 12.3456789000e10,
                     54:       'float -12.3456789000e10' => -12.3456789000e10,
                     55:       'float .5' => .5,
                     56: 
                     57:       // array data
                     58:       'empty array' => array(),
                     59:       'int indexed array' => $index_array,
                     60:       'associative array' => $assoc_array,
                     61:       'nested arrays' => array('foo', $index_array, $assoc_array),
                     62: 
                     63:       // null data
                     64:       'uppercase NULL' => NULL,
                     65:       'lowercase null' => null,
                     66: 
                     67:       // boolean data
                     68:       'lowercase true' => true,
                     69:       'lowercase false' =>false,
                     70:       'uppercase TRUE' =>TRUE,
                     71:       'uppercase FALSE' =>FALSE,
                     72: 
                     73:       // empty data
                     74:       'empty string DQ' => "",
                     75:       'empty string SQ' => '',
                     76: 
                     77:       // object data
                     78:       'instance of classWithToString' => new classWithToString(),
                     79:       'instance of classWithoutToString' => new classWithoutToString(),
                     80: 
                     81:       // undefined data
                     82:       'undefined var' => @$undefined_var,
                     83: 
                     84:       // unset data
                     85:       'unset var' => @$unset_var,
                     86: );
                     87: 
                     88: // loop through each element of the array for format
                     89: 
                     90: foreach($inputs as $key =>$value) {
                     91:       echo "\n--$key--\n";
                     92:       var_dump( gmstrftime($value) );
                     93:       var_dump( gmstrftime($value, $timestamp) );
                     94: };
                     95: 
                     96: ?>
                     97: ===DONE===
                     98: --EXPECTF--
                     99: *** Testing gmstrftime() : usage variation ***
                    100: 
                    101: --int 0--
                    102: string(1) "0"
                    103: string(1) "0"
                    104: 
                    105: --int 1--
                    106: string(1) "1"
                    107: string(1) "1"
                    108: 
                    109: --int 12345--
                    110: string(5) "12345"
                    111: string(5) "12345"
                    112: 
                    113: --int -12345--
                    114: string(6) "-12345"
                    115: string(6) "-12345"
                    116: 
                    117: --float 10.5--
                    118: string(4) "10.5"
                    119: string(4) "10.5"
                    120: 
                    121: --float -10.5--
                    122: string(5) "-10.5"
                    123: string(5) "-10.5"
                    124: 
                    125: --float 12.3456789000e10--
                    126: string(12) "123456789000"
                    127: string(12) "123456789000"
                    128: 
                    129: --float -12.3456789000e10--
                    130: string(13) "-123456789000"
                    131: string(13) "-123456789000"
                    132: 
                    133: --float .5--
                    134: string(3) "0.5"
                    135: string(3) "0.5"
                    136: 
                    137: --empty array--
                    138: 
                    139: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    140: bool(false)
                    141: 
                    142: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    143: bool(false)
                    144: 
                    145: --int indexed array--
                    146: 
                    147: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    148: bool(false)
                    149: 
                    150: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    151: bool(false)
                    152: 
                    153: --associative array--
                    154: 
                    155: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    156: bool(false)
                    157: 
                    158: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    159: bool(false)
                    160: 
                    161: --nested arrays--
                    162: 
                    163: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    164: bool(false)
                    165: 
                    166: Warning: gmstrftime() expects parameter 1 to be string, array given in %s on line %d
                    167: bool(false)
                    168: 
                    169: --uppercase NULL--
                    170: bool(false)
                    171: bool(false)
                    172: 
                    173: --lowercase null--
                    174: bool(false)
                    175: bool(false)
                    176: 
                    177: --lowercase true--
                    178: string(1) "1"
                    179: string(1) "1"
                    180: 
                    181: --lowercase false--
                    182: bool(false)
                    183: bool(false)
                    184: 
                    185: --uppercase TRUE--
                    186: string(1) "1"
                    187: string(1) "1"
                    188: 
                    189: --uppercase FALSE--
                    190: bool(false)
                    191: bool(false)
                    192: 
                    193: --empty string DQ--
                    194: bool(false)
                    195: bool(false)
                    196: 
                    197: --empty string SQ--
                    198: bool(false)
                    199: bool(false)
                    200: 
                    201: --instance of classWithToString--
                    202: string(14) "Class A object"
                    203: string(14) "Class A object"
                    204: 
                    205: --instance of classWithoutToString--
                    206: 
                    207: Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
                    208: bool(false)
                    209: 
                    210: Warning: gmstrftime() expects parameter 1 to be string, object given in %s on line %d
                    211: bool(false)
                    212: 
                    213: --undefined var--
                    214: bool(false)
                    215: bool(false)
                    216: 
                    217: --unset var--
                    218: bool(false)
                    219: bool(false)
                    220: ===DONE===

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