Annotation of embedaddon/php/ext/zlib/tests/gzfile_variation13.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test function gzfile() by substituting agument 2 with object values.
                      3: --SKIPIF--
                      4: <?php
                      5: if (!extension_loaded('zlib')) die ('skip zlib extension not available in this build');
                      6: ?>
                      7: --FILE--
                      8: <?php
                      9: 
                     10: 
                     11: $filename = $filename = dirname(__FILE__)."/004.txt.gz";
                     12: 
                     13: 
                     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: 
                     23: 
                     24: class classWithToString
                     25: {
                     26:         public function __toString() {
                     27:                 return "Class A object";
                     28:         }
                     29: }
                     30: 
                     31: class classWithoutToString
                     32: {
                     33: }
                     34: 
                     35: $variation = array(
                     36:   'instance of classWithToString' => new classWithToString(),
                     37:   'instance of classWithoutToString' => new classWithoutToString(),
                     38:   );
                     39: 
                     40: 
                     41: foreach ( $variation as $var ) {
                     42:   var_dump(gzfile( $filename, $var  ) );
                     43: }
                     44: ?>
                     45: ===DONE===
                     46: --EXPECTF--
                     47: Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
                     48: NULL
                     49: Error: 2 - gzfile() expects parameter 2 to be long, object given, %s(%d)
                     50: NULL
                     51: ===DONE===

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