diff options
Diffstat (limited to 'ext/standard/tests/file/filesize_variation3.phpt')
-rw-r--r-- | ext/standard/tests/file/filesize_variation3.phpt | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/ext/standard/tests/file/filesize_variation3.phpt b/ext/standard/tests/file/filesize_variation3.phpt index 09b9c341ca..bf27c893b6 100644 --- a/ext/standard/tests/file/filesize_variation3.phpt +++ b/ext/standard/tests/file/filesize_variation3.phpt @@ -1,18 +1,7 @@ --TEST-- Test filesize() function: usage variations - file size after truncate ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip only valid for Linux'); -} --FILE-- <?php -/* - Prototype : int filesize ( string $filename ); - Description : Returns the size of the file in bytes, or FALSE - (and generates an error of level E_WARNING) in case of an error. -*/ - $file_path = __DIR__; echo "*** Testing filesize(): usage variations ***\n"; @@ -26,21 +15,24 @@ echo "-- Testing filesize() after truncating the file to a new length --\n"; // truncate the same file, in the loop , each time with the decrement in size by 1200 bytes, // until -1200bytes size for($size = filesize($filename); $size>=-1200; $size-=1200) { - $file_handle = fopen($filename, "r+"); - var_dump( ftruncate($file_handle, $size) ); - fclose($file_handle); - var_dump( filesize($filename) ); - clearstatcache(); + $file_handle = fopen($filename, "r+"); + try { + var_dump( ftruncate($file_handle, $size) ); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + fclose($file_handle); + var_dump( filesize($filename) ); + clearstatcache(); } -echo "*** Done ***\n"; ?> --CLEAN-- <?php $file_path = __DIR__; unlink($file_path."/filesize_variation3.tmp"); ?> ---EXPECTF-- +--EXPECT-- *** Testing filesize(): usage variations *** -- Testing filesize() after truncating the file to a new length -- bool(true) @@ -65,8 +57,5 @@ bool(true) int(1200) bool(true) int(0) - -Warning: ftruncate(): Negative size is not supported in %s on line %d -bool(false) +ftruncate(): Argument #2 ($size) must be greater than or equal to 0 int(0) -*** Done *** |