From: Zoe Slattery Date: Wed, 6 Jun 2007 12:53:58 +0000 (+0000) Subject: New tests for file handling X-Git-Tag: php-5.2.4RC1~408 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=860c643448e3a121634ccd085d9bb2bb80e99f4f;p=php New tests for file handling --- diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt new file mode 100644 index 0000000000..5ad31e967f --- /dev/null +++ b/ext/standard/tests/file/disk_free_space_basic.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test disk_free_space and its alias diskfreespace() functions : basic functionality +--FILE-- + $space2 ) + echo "\n Free Space Value Is Correct\n"; +else + echo "\n Free Space Value Is Incorrect\n"; + +echo"\n-- Done --"; +?> + +--CLEAN-- + + +--EXPECTF-- +*** Testing with existing directory *** +float(%d) +float(%d) +*** Testing with newly created directory *** + + Free Space before writing to a file +float(%d) + + Free Space after writing to a file +float(%d) + + Free Space Value Is Correct + +-- Done -- diff --git a/ext/standard/tests/file/disk_free_space_variation.phpt b/ext/standard/tests/file/disk_free_space_variation.phpt new file mode 100644 index 0000000000..ee72eea465 --- /dev/null +++ b/ext/standard/tests/file/disk_free_space_variation.phpt @@ -0,0 +1,123 @@ +--TEST-- +Test disk_free_space and its alias diskfreespace() functions : usage variations +--FILE-- + + +--CLEAN-- + + +--EXPECTF-- +*** Testing disk_free_space() function with a directory *** +float(%d) +float(%d) + +*** Testing for the return type *** +bool(true) + +*** Testing disk_free_space() function with different styles of file and directory *** +-- Iteration 1 -- +float(%d) +float(%d) + +-- Iteration 2 -- +float(%d) +float(%d) + +-- Iteration 3 -- +float(%d) +float(%d) + +-- Iteration 4 -- +float(%d) +float(%d) + +-- Iteration 5 -- +float(%d) +float(%d) + +-- Iteration 6 -- +float(%d) +float(%d) + +-- Iteration 7 -- +float(%d) +float(%d) + +-- Iteration 8 -- +float(%d) +float(%d) + +-- Iteration 9 -- +float(%d) +float(%d) + +-- Iteration 10 -- +float(%d) +float(%d) + +-- Iteration 11 -- +float(%d) +float(%d) + +-- Iteration 12 -- +float(%d) +float(%d) + +--- Done --- diff --git a/ext/standard/tests/file/disk_total_space_basic.phpt b/ext/standard/tests/file/disk_total_space_basic.phpt new file mode 100644 index 0000000000..caf7452e41 --- /dev/null +++ b/ext/standard/tests/file/disk_total_space_basic.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test disk_total_space() function : basic functionality +--FILE-- + + +--CLEAN-- + + +--EXPECTF-- +*** Testing with existing directory *** +float(%d) +*** Testing with newly created directory *** +float(%d) + + Total Space after writing to a file +float(%d) + +--- Done --- diff --git a/ext/standard/tests/file/disk_total_space_variation.phpt b/ext/standard/tests/file/disk_total_space_variation.phpt new file mode 100644 index 0000000000..f722883a3c --- /dev/null +++ b/ext/standard/tests/file/disk_total_space_variation.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test disk_total_space() functions : usage variations +--FILE-- + + +--CLEAN-- + +--EXPECTF-- +*** Testing with a directory *** +float(%d) + +Testing for the return type *** +bool(true) + +*** Testing disk_total_space() function with different directory combinations *** +-- Iteration 1 -- +float(%d) + +-- Iteration 2 -- +float(%d) + +-- Iteration 3 -- +float(%d) + +-- Iteration 4 -- +float(%d) + +-- Iteration 5 -- +float(%d) + +-- Iteration 6 -- +float(%d) + +-- Iteration 7 -- +float(%d) + +-- Iteration 8 -- +float(%d) + +-- Iteration 9 -- +float(%d) + +-- Iteration 10 -- +float(%d) + +-- Iteration 11 -- +float(%d) + +-- Iteration 12 -- +float(%d) + +--- Done --- diff --git a/ext/standard/tests/file/file_basic.phpt b/ext/standard/tests/file/file_basic.phpt new file mode 100644 index 0000000000..cb15a52c83 --- /dev/null +++ b/ext/standard/tests/file/file_basic.phpt @@ -0,0 +1,76 @@ +--TEST-- +Test file() function : basic functionality +--FILE-- + +--EXPECTF-- +*** Testing file() with basic files *** +Array +( + [0] => 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 +) +Array +( + [0] => text text text text text text text text text text text text text text text text text text text text +) +Array +( +) +Array +( + [0] => line + + [1] => line of text + + [2] => line + + [3] => line of text + + [4] => line + + [5] => line of text + + [6] => line + + [7] => line of text + + [8] => line + + [9] => line of text + + [10] => line + + [11] => line +) +*** Testing for return type of file function *** +bool(true) +bool(true) +bool(true) +bool(true) + +--- Done --- diff --git a/ext/standard/tests/file/file_error.phpt b/ext/standard/tests/file/file_error.phpt new file mode 100644 index 0000000000..e2562d3e23 --- /dev/null +++ b/ext/standard/tests/file/file_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +Testing file() function : error conditions +--FILE-- + + +--CLEAN-- + +--EXPECTF-- +*** Testing error conditions *** +Warning: file() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: file() expects at most 3 parameters, 4 given in %s on line %d +NULL + +Warning: file() expects parameter 2 to be long, string given in %s on line %d +NULL +array(0) { +} + +Warning: file(nofile.tmp): failed to open stream: No such file or directory in %s on line %d +bool(false) + +--- Done --- diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt new file mode 100644 index 0000000000..edfad0d945 --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test file_put_contents() and file_get_contents() functions : basic functionality +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing the basic functionality of file_put_contents() and file_get_contents() functions *** +-- Testing with simple valid data file -- +string(100) "text text text text text text text text text text text text text text text text text text text text " + +-- Testing with empty file -- +string(0) "" + +*** Done *** diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt new file mode 100644 index 0000000000..72fe121533 --- /dev/null +++ b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt @@ -0,0 +1,71 @@ +--TEST-- +Test file-get_contents() and file_put_contents() functions : error conditions +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing error conditions *** + +-- Testing with Non-existing file -- + +Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d + +-- Testing No.of arguments less than expected -- + +Warning: file_get_contents() expects at least 1 parameter, 0 given in %s on line %d + +Warning: file_put_contents() expects at least 2 parameters, 0 given in %s on line %d + +Warning: file_put_contents() expects at least 2 parameters, 1 given in %s on line %d + +-- Testing No.of arguments greater than expected -- + +Warning: file_put_contents() expects at most 4 parameters, 5 given in %s on line %d + +Warning: file_get_contents() expects at most 5 parameters, 6 given in %s on line %d + +-- Testing for invalid negative maxlen values -- +Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d +bool(false) + +*** Done *** diff --git a/ext/standard/tests/file/file_variation.phpt b/ext/standard/tests/file/file_variation.phpt new file mode 100644 index 0000000000..b83148ba8d --- /dev/null +++ b/ext/standard/tests/file/file_variation.phpt @@ -0,0 +1,265 @@ +--TEST-- +Test file() function : usage variations +--FILE-- + + +--CLEAN-- + +--EXPECTF-- +*** Using various flags values with different data in a file +--Iteration 1 -- +array(1) { + [0]=> + string(12) "Garbage data" +} +array(1) { + [0]=> + string(12) "Garbage data" +} +--Iteration 2 -- +array(4) { + [0]=> + string(3) "Gar" + [1]=> + string(2) "ba" + [2]=> + string(4) "ge d" + [3]=> + string(3) "ata" +} +array(4) { + [0]=> + string(4) "Gar +" + [1]=> + string(3) "ba +" + [2]=> + string(5) "ge d +" + [3]=> + string(3) "ata" +} +--Iteration 3 -- +array(5) { + [0]=> + string(3) "Gar" + [1]=> + string(0) "" + [2]=> + string(5) "bage " + [3]=> + string(0) "" + [4]=> + string(5) " data" +} +array(5) { + [0]=> + string(4) "Gar +" + [1]=> + string(1) " +" + [2]=> + string(6) "bage +" + [3]=> + string(1) " +" + [4]=> + string(5) " data" +} +*** Testing with variation in use_include_path argument *** +array(1) { + [0]=> + string(100) "text text text text text text text text text text text text text text text text text text text text " +} +array(1) { + [0]=> + string(100) "text text text text text text text text text text text text text text text text text text text text " +} +array(1) { + [0]=> + string(100) "text text text text text text text text text text text text text text text text text text text text " +} +array(1) { + [0]=> + string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" +} +array(1) { + [0]=> + string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" +} +array(1) { + [0]=> + string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" +} +array(1) { + [0]=> + string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 " +} +array(1) { + [0]=> + string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 " +} +array(1) { + [0]=> + string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 " +} +array(12) { + [0]=> + string(5) "line +" + [1]=> + string(13) "line of text +" + [2]=> + string(5) "line +" + [3]=> + string(13) "line of text +" + [4]=> + string(5) "line +" + [5]=> + string(13) "line of text +" + [6]=> + string(5) "line +" + [7]=> + string(13) "line of text +" + [8]=> + string(5) "line +" + [9]=> + string(13) "line of text +" + [10]=> + string(5) "line +" + [11]=> + string(5) "line " +} +array(12) { + [0]=> + string(4) "line" + [1]=> + string(12) "line of text" + [2]=> + string(4) "line" + [3]=> + string(12) "line of text" + [4]=> + string(4) "line" + [5]=> + string(12) "line of text" + [6]=> + string(4) "line" + [7]=> + string(12) "line of text" + [8]=> + string(4) "line" + [9]=> + string(12) "line of text" + [10]=> + string(4) "line" + [11]=> + string(5) "line " +} +array(12) { + [0]=> + string(5) "line +" + [1]=> + string(13) "line of text +" + [2]=> + string(5) "line +" + [3]=> + string(13) "line of text +" + [4]=> + string(5) "line +" + [5]=> + string(13) "line of text +" + [6]=> + string(5) "line +" + [7]=> + string(13) "line of text +" + [8]=> + string(5) "line +" + [9]=> + string(13) "line of text +" + [10]=> + string(5) "line +" + [11]=> + string(5) "line " +} + +--- Done --- diff --git a/ext/standard/tests/file/is_executable_variation.phpt b/ext/standard/tests/file/is_executable_variation.phpt new file mode 100644 index 0000000000..c346150e0c --- /dev/null +++ b/ext/standard/tests/file/is_executable_variation.phpt @@ -0,0 +1,190 @@ +--TEST-- +Test is_executable() function: usage variations +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing is_executable(): usage variations *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) + +*** Testing is_executable() on directory without execute permission *** +bool(false) + +*** Testing miscelleneous input for is_executable() function *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(true) + +*** Testing is_executable() on invalid files *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(false) +bool(false) +Done diff --git a/ext/standard/tests/file/is_readable_variation.phpt b/ext/standard/tests/file/is_readable_variation.phpt new file mode 100644 index 0000000000..68c3bcb8ae --- /dev/null +++ b/ext/standard/tests/file/is_readable_variation.phpt @@ -0,0 +1,193 @@ +--TEST-- +Test is_readable() function: usage variations +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing is_readable(): usage variations *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) +-- Iteration 11 -- +bool(true) + +*** Testing is_readable() on directory without read permission *** +bool(false) + +*** Testing miscelleneous input for is_readable() function *** +-- Iteration 1 -- +bool(true) +-- Iteration 2 -- +bool(true) +-- Iteration 3 -- +bool(true) +-- Iteration 4 -- +bool(true) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(true) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(true) + +*** Testing is_readable() on miscelleneous filenames *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(false) +bool(false) +Done diff --git a/ext/standard/tests/file/is_writable_variation.phpt b/ext/standard/tests/file/is_writable_variation.phpt new file mode 100644 index 0000000000..b19df2daf3 --- /dev/null +++ b/ext/standard/tests/file/is_writable_variation.phpt @@ -0,0 +1,234 @@ +--TEST-- +Test is_writable() and its alias is_writeable() function: usage variations +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing is_writable(): usage variations *** +-- Iteration 1 -- +bool(true) +bool(true) +-- Iteration 2 -- +bool(false) +bool(false) +-- Iteration 3 -- +bool(true) +bool(true) +-- Iteration 4 -- +bool(true) +bool(true) +-- Iteration 5 -- +bool(false) +bool(false) +-- Iteration 6 -- +bool(false) +bool(false) +-- Iteration 7 -- +bool(true) +bool(true) +-- Iteration 8 -- +bool(true) +bool(true) +-- Iteration 9 -- +bool(true) +bool(true) +-- Iteration 10 -- +bool(true) +bool(true) +-- Iteration 11 -- +bool(true) +bool(true) + +*** Testing is_writable() on directory without write permission *** +bool(false) +bool(false) + +*** Testing miscelleneous input for is_writable() function *** +-- Iteration 1 -- +bool(true) +bool(true) +-- Iteration 2 -- +bool(true) +bool(true) +-- Iteration 3 -- +bool(true) +bool(true) +-- Iteration 4 -- +bool(false) +bool(false) +-- Iteration 5 -- +bool(true) +bool(true) +-- Iteration 6 -- +bool(true) +bool(true) +-- Iteration 7 -- +bool(false) +bool(false) +-- Iteration 8 -- +bool(true) +bool(true) +-- Iteration 9 -- +bool(false) +bool(false) +-- Iteration 10 -- +bool(false) +bool(false) + +*** Testing is_writable() on miscelleneous filenames *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(false) + +Notice: Array to string conversion in %s on line %d +bool(false) +bool(false) +bool(false) +Done