File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / output / ob_implicit_flush_variation_001.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Test ob_implicit_flush() function : usage variation 
    3: --FILE--
    4: <?php
    5: /* Prototype  : void ob_implicit_flush([int flag])
    6:  * Description: Turn implicit flush on/off and is equivalent to calling flush() after every output call 
    7:  * Source code: main/output.c
    8:  * Alias to functions: 
    9:  */
   10: 
   11: echo "*** Testing ob_implicit_flush() : usage variation ***\n";
   12: 
   13: // Define error handler
   14: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
   15: 	if (error_reporting() != 0) {
   16: 		// report non-silenced errors
   17: 		echo "Error: $err_no - $err_msg, $filename($linenum)\n";
   18: 	}
   19: }
   20: set_error_handler('test_error_handler');
   21: 
   22: // Initialise function arguments not being substituted (if any)
   23: 
   24: //get an unset variable
   25: $unset_var = 10;
   26: unset ($unset_var);
   27: 
   28: // define some classes
   29: class classWithToString
   30: {
   31: 	public function __toString() {
   32: 		return "Class A object";
   33: 	}
   34: }
   35: 
   36: class classWithoutToString
   37: {
   38: }
   39: 
   40: // heredoc string
   41: $heredoc = <<<EOT
   42: hello world
   43: EOT;
   44: 
   45: // add arrays
   46: $index_array = array (1, 2, 3);
   47: $assoc_array = array ('one' => 1, 'two' => 2);
   48: 
   49: //array of values to iterate over
   50: $inputs = array(
   51: 
   52:       // float data
   53:       'float 10.5' => 10.5,
   54:       'float -10.5' => -10.5,
   55:       'float 12.3456789000e10' => 12.3456789000e10,
   56:       'float -12.3456789000e10' => -12.3456789000e10,
   57:       'float .5' => .5,
   58: 
   59:       // array data
   60:       'empty array' => array(),
   61:       'int indexed array' => $index_array,
   62:       'associative array' => $assoc_array,
   63:       'nested arrays' => array('foo', $index_array, $assoc_array),
   64: 
   65:       // null data
   66:       'uppercase NULL' => NULL,
   67:       'lowercase null' => null,
   68: 
   69:       // boolean data
   70:       'lowercase true' => true,
   71:       'lowercase false' =>false,
   72:       'uppercase TRUE' =>TRUE,
   73:       'uppercase FALSE' =>FALSE,
   74: 
   75:       // empty data
   76:       'empty string DQ' => "",
   77:       'empty string SQ' => '',
   78: 
   79:       // string data
   80:       'string DQ' => "string",
   81:       'string SQ' => 'string',
   82:       'mixed case string' => "sTrInG",
   83:       'heredoc' => $heredoc,
   84: 
   85:       // object data
   86:       'instance of classWithToString' => new classWithToString(),
   87:       'instance of classWithoutToString' => new classWithoutToString(),
   88: 
   89:       // undefined data
   90:       'undefined var' => @$undefined_var,
   91: 
   92:       // unset data
   93:       'unset var' => @$unset_var,
   94: );
   95: 
   96: // loop through each element of the array for flag
   97: 
   98: foreach($inputs as $key =>$value) {
   99:       echo "\n--$key--\n";
  100:       var_dump( ob_implicit_flush($value) );
  101: };
  102: 
  103: ?>
  104: --EXPECTF--
  105: *** Testing ob_implicit_flush() : usage variation ***
  106: 
  107: --float 10.5--
  108: NULL
  109: 
  110: --float -10.5--
  111: NULL
  112: 
  113: --float 12.3456789000e10--
  114: NULL
  115: 
  116: --float -12.3456789000e10--
  117: NULL
  118: 
  119: --float .5--
  120: NULL
  121: 
  122: --empty array--
  123: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
  124: NULL
  125: 
  126: --int indexed array--
  127: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
  128: NULL
  129: 
  130: --associative array--
  131: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
  132: NULL
  133: 
  134: --nested arrays--
  135: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, array given, %s(97)
  136: NULL
  137: 
  138: --uppercase NULL--
  139: NULL
  140: 
  141: --lowercase null--
  142: NULL
  143: 
  144: --lowercase true--
  145: NULL
  146: 
  147: --lowercase false--
  148: NULL
  149: 
  150: --uppercase TRUE--
  151: NULL
  152: 
  153: --uppercase FALSE--
  154: NULL
  155: 
  156: --empty string DQ--
  157: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  158: NULL
  159: 
  160: --empty string SQ--
  161: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  162: NULL
  163: 
  164: --string DQ--
  165: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  166: NULL
  167: 
  168: --string SQ--
  169: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  170: NULL
  171: 
  172: --mixed case string--
  173: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  174: NULL
  175: 
  176: --heredoc--
  177: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, %unicode_string_optional% given, %s(97)
  178: NULL
  179: 
  180: --instance of classWithToString--
  181: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, object given, %s(97)
  182: NULL
  183: 
  184: --instance of classWithoutToString--
  185: Error: 2 - ob_implicit_flush() expects parameter 1 to be long, object given, %s(97)
  186: NULL
  187: 
  188: --undefined var--
  189: NULL
  190: 
  191: --unset var--
  192: NULL

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