dkelsey Thu Jan 22 20:49:48 2009 UTC Modified files: /php-src/ext/standard/tests/file fstat_error.phpt fstat_variation6.phpt fstat_variation3.phpt fstat_basic.phpt fstat_variation2.phpt directory_wrapper_fstat_basic.phpt fstat_variation5.phpt fstat_variation7.phpt fstat_variation8.phpt fstat_variation4.phpt fstat_variation1.phpt Log: fstat tests. tested on windows, linux and linux 64 bit
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_error.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_error.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_error.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,22 @@ +--TEST-- +Test function fstat() by calling it more than or less than its expected arguments +--FILE-- +<?php +$fp = fopen (__FILE__, 'r'); +$extra_arg = 'nothing'; + +var_dump(fstat( $fp, $extra_arg ) ); +var_dump(fstat()); + +fclose($fp); + +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: fstat() expects exactly 1 parameter, 0 given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation6.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation6.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,46 @@ +--TEST-- +Test function fstat() by substituting agument 1 with object values. +--FILE-- +<?php + + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- +Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d) +NULL +Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d) +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation3.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation3.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,42 @@ +--TEST-- +Test function fstat() by substituting agument 1 with emptyUnsetUndefNull values. +--FILE-- +<?php +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_basic.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_basic.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_basic.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,65 @@ +--TEST-- +Test function fstat() by calling it with its expected arguments +--FILE-- +<?php +$fp = fopen (__FILE__, 'r'); +var_dump(fstat( $fp ) ); +fclose($fp); +?> +===DONE=== +--EXPECTF-- +array(26) { + [0]=> + int(%i) + [1]=> + int(%i) + [2]=> + int(%i) + [3]=> + int(%i) + [4]=> + int(%i) + [5]=> + int(%i) + [6]=> + int(%i) + [7]=> + int(%i) + [8]=> + int(%i) + [9]=> + int(%i) + [10]=> + int(%i) + [11]=> + int(%i) + [12]=> + int(%i) + [u"dev"]=> + int(%i) + [u"ino"]=> + int(%i) + [u"mode"]=> + int(%i) + [u"nlink"]=> + int(%i) + [u"uid"]=> + int(%i) + [u"gid"]=> + int(%i) + [u"rdev"]=> + int(%i) + [u"size"]=> + int(%i) + [u"atime"]=> + int(%i) + [u"mtime"]=> + int(%i) + [u"ctime"]=> + int(%i) + [u"blksize"]=> + int(%i) + [u"blocks"]=> + int(%i) +} +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation2.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation2.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,31 @@ +--TEST-- +Test function fstat() by substituting agument 1 with boolean values. +--FILE-- +<?php +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt diff -u /dev/null php-src/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,13 @@ +--TEST-- +Test function fstat() on directory wrapper +--FILE-- +<?php +$d = dirname(__FILE__); +$h = opendir($d); +var_dump(fstat($h)); +closedir($h); +?> +===DONE=== +--EXPECT-- +bool(false) +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation5.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation5.phpt Thu Jan 22 20:49:47 2009 @@ -0,0 +1,31 @@ +--TEST-- +Test function fstat() by substituting agument 1 with int values. +--FILE-- +<?php +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation7.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation7.phpt Thu Jan 22 20:49:48 2009 @@ -0,0 +1,35 @@ +--TEST-- +Test function fstat() by substituting agument 1 with string values. +--FILE-- +<?php +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, Unicode string given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation8.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation8.phpt Thu Jan 22 20:49:48 2009 @@ -0,0 +1,33 @@ +--TEST-- +Test function fstat() by calling it with its expected arguments +--FILE-- +<?php +$stat_result = stat(__FILE__); +clearstatcache(); +$fp = fopen (__FILE__, 'r'); +$fstat_result = fstat($fp); +fclose($fp); + +$isWin = (substr(PHP_OS, 0, 3) == 'WIN'); +$failed = false; +foreach($stat_result as $key =>$value) { + if ($isWin && ($key === 0 || $key === 6 || $key === 'dev' || $key === 'rdev')) { + // windows, dev and rdev will not match this is expected + } + else { + if ($fstat_result[$key] != $value) { + echo "FAIL: stat differs at '$key'. $fstat_result[$key] -- $value\n"; + $failed = true; + } + } +} +if ($failed !== true) { + echo "PASSED: all elements are the same\n"; +} + + +?> +===DONE=== +--EXPECT-- +PASSED: all elements are the same +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation4.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation4.phpt Thu Jan 22 20:49:48 2009 @@ -0,0 +1,35 @@ +--TEST-- +Test function fstat() by substituting agument 1 with float values. +--FILE-- +<?php +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fstat_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fstat_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/file/fstat_variation1.phpt:1.2 --- /dev/null Thu Jan 22 20:49:48 2009 +++ php-src/ext/standard/tests/file/fstat_variation1.phpt Thu Jan 22 20:49:48 2009 @@ -0,0 +1,34 @@ +--TEST-- +Test function fstat() by substituting agument 1 with array values. +--FILE-- +<?php +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(fstat( $var ) ); +} +?> +===DONE=== +--EXPECTF-- + +Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d +NULL + +Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d +NULL +===DONE=== \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php