zoe             Wed Jun  6 12:50:06 2007 UTC

  Added files:                 
    /php-src/ext/standard/tests/file    disk_total_space_basic.phpt 
                                        file_basic.phpt 
                                        is_executable_variation.phpt 
                                        
file_get_contents_file_put_contents_basic.phpt 
                                        disk_total_space_variation.phpt 
                                        disk_free_space_basic.phpt 
                                        file_variation.phpt 
                                        is_writable_variation.phpt 
                                        is_readable_variation.phpt 
                                        disk_free_space_variation.phpt 
                                        file_error.phpt 
                                        
file_get_contents_file_put_contents_error.phpt 
  Log:
  New tests for file handling
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/disk_total_space_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/disk_total_space_basic.phpt
+++ php-src/ext/standard/tests/file/disk_total_space_basic.phpt
--TEST--
Test disk_total_space() function : basic functionality
--FILE--
<?php
/*
 *  Prototype: float disk_total_space( string $directory );
 *  Description: given a string containing a directory, this function will 
 *               return the total number of bytes on the corresponding 
filesyatem
 *               or disk partition.
 */

$file_path = dirname(__FILE__);

echo "*** Testing with normal directory ***\n";
var_dump( disk_total_space($file_path) );

echo "*** Testing with newly created directory ***\n";
$dir = "/disk_total_space";

mkdir($file_path.$dir);
var_dump( disk_total_space($file_path.$dir) );
$fh = fopen($file_path.$dir."/disk_total_space.tmp", "w");
fwrite($fh, (binary)"Garbage Data Garbage Data Garbage Data Garbage Data 
Garbage Data Garbage Data Garbage Data");

fclose($fh);

echo"\nTotal Space after writing to a file\n";
var_dump( disk_total_space($file_path.$dir) );

echo"\n-- Done --";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/disk_total_space/disk_total_space.tmp");
rmdir($file_path."/disk_total_space");
?>

--EXPECTF--
*** Testing with normal directory ***
float(%d)
*** Testing with newly created directory ***
float(%d)

Total Space after writing to a file
float(%d)

-- Done --
--UEXPECTF--
*** Testing with normal directory ***
float(%d)
*** Testing with newly created directory ***
float(%d)

Total Space after writing to a file
float(%d)

-- Done --

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/file_basic.phpt
+++ php-src/ext/standard/tests/file/file_basic.phpt
--TEST--
Test file() function : basic functionality
--FILE--
<?php
/* 
 * Prototype: array file ( string filename [,int use-include_path [,resource 
context]] );
 * Description: Reads entire file into an array
 *              Returns the  file in an array
 */
require(dirname(__FILE__) . '/file.inc');
$file_path = dirname(__FILE__);
echo "*** Testing file() with basic types of files ***\n";
$filetypes = array("numeric", "text", "empty", "text_with_new_line");

foreach( $filetypes as $type ) {
  create_files($file_path, 1, $type, 0755, 100, "w", "file", 1, "byte");
  print_r( file($file_path."/file1.tmp") );
  delete_files($file_path, 1);
}

echo "*** Testing for return type of file() function ***\n";
foreach( $filetypes as $type ) {
  create_files($file_path, 1, $type);
  $ret_arr =  file($file_path."/file1.tmp");
  var_dump( is_array($ret_arr) );
  delete_files($file_path, 1);
}

echo "\n--- Done ---";
?>
--EXPECTF--
*** Testing file() with basic types of 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 ---

--UEXPECTF--
*** Testing file() with basic types of 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 ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_executable_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_executable_variation.phpt
+++ php-src/ext/standard/tests/file/is_executable_variation.phpt
--TEST--
Test is_executable() function: usage variations
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
    die('skip.. only for LINUX');
}
?>
--FILE--
<?php
/* Prototype: bool is_executable ( string $filename );
   Description: Tells whether the filename is executable
*/

require dirname(__FILE__).'/file.inc';
echo "*** Testing is_executable(): usage variations ***\n";

$file_path = dirname(__FILE__);
mkdir("$file_path/is_executable");

// create a new temporary file
$fp = fopen("$file_path/is_executable/bar.tmp", "w");
fclose($fp);

/* array of files checked to see if they are executable files
   using is_executable() function */
$files_arr = array(
  "$file_path/is_executable/bar.tmp",

  /* Testing a file with trailing slash */
  "$file_path/is_executable/bar.tmp/",

  /* Testing file with double slashes */
  "$file_path/is_executable//bar.tmp",
  "$file_path/is_executable/*.tmp",
  "$file_path/is_executable/b*.tmp", 

  /* Testing Binary safe */
  "$file_path/is_executable".chr(0)."bar.temp",
  "$file_path".chr(0)."is_executable/bar.temp",
  "$file_path/is_executablex000/",
  
  /* Testing directories */
  ".",  // current directory, exp: bool(true)
  "$file_path/is_executable"  // temp directory, exp: bool(true)
);
$counter = 1;
/* loop through to test each element in the above array 
   is an executable file */
foreach($files_arr as $file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_executable($file) );
  $counter++;
  clearstatcache();
}

echo "\n*** Testing is_executable() on directory without execute permission 
***\n";
chmod("$file_path/is_executable", 0444);
var_dump( is_executable("$file_path/is_executable") );  // exp: bool(false)
chmod("$file_path/is_executable", 0777);  // chmod to enable deletion of 
directory

echo "\n*** Testing miscelleneous input for is_executable() function ***\n";
$name_prefix = "is_executable";
create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 4);
create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
create_files(dirname(__FILE__), 1, "text", 0714, 1, "w", $name_prefix, 7);
create_files(dirname(__FILE__), 1, "numeric", 0744, 1, "w", $name_prefix, 8);
create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
create_files(dirname(__FILE__), 1, "text", 0712, 1, "w", $name_prefix, 10);

$files = array (
  "$file_path/is_executable1.tmp",
  "$file_path/is_executable2.tmp",
  "$file_path/is_executable3.tmp",
  "$file_path/is_executable4.tmp",
  "$file_path/is_executable5.tmp",
  "$file_path/is_executable6.tmp",
  "$file_path/is_executable7.tmp",
  "$file_path/is_executable8.tmp",
  "$file_path/is_executable9.tmp",
  "$file_path/is_executable10.tmp",
);
$counter = 1;
/* loop through to test each element in the above array
   is an executable file */
foreach($files as $file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_executable($file) );
  $counter++;
  clearstatcache();
}

// change all file's permissions to 777 before deleting
change_file_perms($file_path, 10, 0777, $name_prefix);
delete_files($file_path, 10, $name_prefix);

$file_handle = fopen(__FILE__, "r");
unset($file_handle);

echo "\n*** Testing is_executable() on invalid files ***\n";
$invalid_files = array(
  0,
  1234,
  -2.34555,
  "string",
  TRUE,
  FALSE,
  NULL,
  @array(),
  @$file_handle
);
/* loop through to test each element in the above array 
   is an executable file */
foreach( $invalid_files as $invalid_file ) {
  var_dump( is_executable($invalid_file) );
  clearstatcache();
}

echo "Done\n";
?>
--CLEAN--
<?php
unlink(dirname(__FILE__)."/is_executable/bar.tmp");
rmdir(dirname(__FILE__)."/is_executable/");
?>
--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)

Warning: is_executable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)
Done
--UEXPECTF--
*** 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)

Warning: is_executable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt?view=markup&rev=1.1
Index: 
php-src/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt
+++ 
php-src/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt
--TEST--
Test file_put_contents() and file_get_contents() functions : basic functionality
--FILE--
<?php

/* Prototype: string file_get_contents( string $filename[, bool 
$use_include_path[, 
 *                                      resource $context[, int $offset[, int 
$maxlen]]]] )
 * Description: Reads entire file into a string
 */

/* Prototype: int file_put_contents( string $filename, mixed $data[, int 
$flags[, resource $context]] )
 * Description: Write a string to a file
 */

$file_path = dirname(__FILE__);
include($file_path."/file.inc");
$filename = "/file_get_contents.tmp";

echo "*** Testing the basic functionality ***\n";

echo "-- Testing with simple valid data file --\n";

fill_buffer($text_buffer, "text", 100);
file_put_contents( $file_path.$filename, (binary)$text_buffer );

var_dump( file_get_contents($file_path.$filename) );

echo "\n-- Testing with empty file --\n";

$filename = "/file_get_contents1.tmp";
file_put_contents( $file_path.$filename, "");
var_dump( file_get_contents( $file_path.$filename ) );

echo "\n*** Done ***";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/file_get_contents.tmp");
unlink($file_path."/file_get_contents1.tmp");
?>
--EXPECTF--
*** Testing the basic functionality ***
-- 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 ***

--UEXPECTF--
*** Testing the basic functionality ***
-- 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 ***

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/disk_total_space_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/disk_total_space_variation.phpt
+++ php-src/ext/standard/tests/file/disk_total_space_variation.phpt
--TEST--
Testing disk_total_space() functions : Usage Variations.
--FILE--
<?php
/*
 *  Prototype: float disk_total_space( string directory )
 *  Description: given a string containing a directory, this function 
 *               will return the total number of bytes on the corresponding 
 *               filesystem or disk partition.
 */

$file_path = dirname(__FILE__);

echo "*** Testing with a directory ***\n";
var_dump( disk_total_space($file_path."/..") ); 

echo "\nTesting for the return type ***\n";
$return_value = disk_total_space($file_path); 
var_dump( is_float($return_value) );

echo "\n*** Testing with different directory combinations ***";
$dir = "/disk_total_space";

mkdir($file_path.$dir);

$dirs_arr = array(
  ".",
  $file_path.$dir,
  $file_path."/.".$dir,

  /* Testing a file trailing slash */
  $file_path."".$dir."/",
  $file_path."/.".$dir."/",

  /* Testing file with double trailing slashes */
  $file_path.$dir."//",
  $file_path."/.".$dir."//",
  $file_path."/./".$dir."//",

  /* Testing Binary safe */
  $file_path.$dir.chr(0),
  $file_path."/.".$dir.chr(0),
  ".".chr(0).$file_path.$dir,
  ".".chr(0).$file_path.$dir.chr(0)
);


$count = 1;
/* loop through to test each element the above array */
foreach($dirs_arr as $dir1) {
  echo "\n-- Iteration $count --\n";
  var_dump( disk_total_space( $dir1 ) );
  $count++;
}

echo "*** Testing with Binary Input ***\n";
var_dump( disk_total_space(b"$file_path") ); 

echo"\n--- Done ---";
?>

--CLEAN--
<?php
$file_path = dirname(__FILE__);
rmdir($file_path."/disk_total_space");
?>


--EXPECTF--
*** Testing with a directory ***
float(%d)

Testing for the return type ***
bool(true)

*** Testing 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)
*** Testing with Binary Input ***
float(%d)

--- Done ---
--UEXPECTF--
*** Testing with a directory ***
float(%d)

Testing for the return type ***
bool(true)

*** Testing 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)
*** Testing with Binary Input ***
float(%d)

--- Done ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/disk_free_space_basic.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/disk_free_space_basic.phpt
+++ php-src/ext/standard/tests/file/disk_free_space_basic.phpt
--TEST--
Test disk_free_space and its alias diskfreespace() functions : basic 
functionality
--FILE--
<?php
/*
 *  Prototype: float disk_free_space( string directory )
 *  Description: Given a string containing a directory, this function 
 *               will return the number of bytes available on the corresponding 
 *               filesystem or disk partition
 */

$file_path = dirname(__FILE__);

echo "*** Testing with existing directory ***\n";
var_dump( disk_free_space($file_path) ); 
var_dump( diskfreespace($file_path) ); 

echo "*** Testing with newly created directory ***\n";
$dir = "/disk_free_space";
mkdir($file_path.$dir);
echo" \n Free Space before writing to a file\n";
$space1 =  disk_free_space($file_path.$dir); 
var_dump( $space1 ); 

$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
for( $i=1; $i<=1000; $i++)
fwrite($fh, (binary)"x");
fclose($fh);

echo "\n Free Space after writing to a file\n";
$space2 =  disk_free_space($file_path.$dir); 
var_dump( $space2 ); 

if( $space1 > $space2 )
  echo "\n Free Space Value Is Correct\n";
else
  echo "\n Free Space Value Is Incorrect\n";

echo "*** Testing with Binary Input ***\n";
var_dump( disk_free_space(b"$file_path") ); 

echo"\n--- Done ---";
?>

--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/disk_free_space/disk_free_space.tmp");
rmdir($file_path."/disk_free_space");
?>

--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
*** Testing with Binary Input ***
float(%d)

--- Done ---
--UEXPECTF--
*** 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
*** Testing with Binary Input ***
float(%d)

--- Done ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/file_variation.phpt
+++ php-src/ext/standard/tests/file/file_variation.phpt
--TEST--
Test file() function : Variations
--FILE--
<?php
/* 
 *  Prototype: array file ( string filename [,int use-include_path [,resource 
context]] );
 *  Description: Reads entire file into an array
                 Returns the  file in an array
 */
require(dirname(__FILE__) . '/file.inc');

$data_array = array( "Garbage data", "Gar\nba\nge d\nata", "Gar\n\nbage \n\n 
data" );
echo "*** Using various flags values with different data in a file\n";
$count=1;
$file_path = dirname(__FILE__);
foreach( $data_array as $data ) {
   echo "--Iteration $count --\n";
   $fh  = fopen($file_path."/file.tmp", "w");
   fwrite($fh, (binary)$data);
   var_dump( file($file_path."/file.tmp", FILE_IGNORE_NEW_LINES) ); 
   var_dump( file($file_path."/file.tmp", FILE_SKIP_EMPTY_LINES) ); 
   $count++;
   fclose($fh);
}

echo "*** Testing with variation in use_include_path argument ***\n";
$file_path1 = dirname(__FILE__)."/file";
mkdir($file_path1);
ini_set( 'include_path',$file_path.'/file' );

file_put_contents( $file_path1."/file1.tmp", 
"aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222" );
var_dump( file("file1.tmp", FILE_USE_INCLUDE_PATH) );
var_dump( file($file_path1."/file1.tmp", 1) );

echo "*** Using file function to remove line containing a key string ***\n";
$file_handle = fopen($file_path."/file2.tmp", "w");
$key = "SEARCH_KEY";
fwrite( $file_handle, (binary)"The key string to be searched is 
SEARCH_KEY\nLine without key string\nThe key string to be searched is 
SEARCH_KEY" );
$out_array = file($file_path."/file2.tmp");

echo "File contents in array form Before replacement of the key\n";
var_dump( $out_array );
$file_handle2 = fopen($file_path."/file3.tmp", "w");
// Loop through file content array
foreach($out_array as $line) {
  if( !strstr( $line, $key ) )
    fputs($file_handle2,$line);
}
echo "File contents in array form After replacement of the key\n";
var_dump( file($file_path."/file3.tmp" ));
fclose($file_handle);
fclose($file_handle2);

echo "\n--- Done ---";
?>

--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/file.tmp");
unlink($file_path."/file/file1.tmp");
unlink($file_path."/file2.tmp");
unlink($file_path."/file3.tmp");
rmdir($file_path."/file");

?>
--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(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
}
array(1) {
  [0]=>
  string(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
}
*** Using file function to remove line containing a key string ***
File contents in array form Before replacement of the key
array(3) {
  [0]=>
  string(44) "The key string to be searched is SEARCH_KEY
"
  [1]=>
  string(24) "Line without key string
"
  [2]=>
  string(43) "The key string to be searched is SEARCH_KEY"
}
File contents in array form After replacement of the key
array(1) {
  [0]=>
  string(24) "Line without key string
"
}

--- Done ---

--UEXPECTF--
*** 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(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
}
array(1) {
  [0]=>
  string(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
}
*** Using file function to remove line containing a key string ***
File contents in array form Before replacement of the key
array(3) {
  [0]=>
  string(44) "The key string to be searched is SEARCH_KEY
"
  [1]=>
  string(24) "Line without key string
"
  [2]=>
  string(43) "The key string to be searched is SEARCH_KEY"
}
File contents in array form After replacement of the key
array(1) {
  [0]=>
  string(24) "Line without key string
"
}

--- Done ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_writable_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_writable_variation.phpt
+++ php-src/ext/standard/tests/file/is_writable_variation.phpt
--TEST--
Test is_writable() and its alias is_writeable() function: usage variations
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
    die('skip.. only for LINUX');
}
?>
--FILE--
<?php
/* Prototype: bool is_writable ( string $filename );
   Description: Tells whether the filename is writable.

   is_writeable() is an alias of is_writable()
*/

require dirname(__FILE__).'/file.inc';
echo "*** Testing is_writable(): usage variations ***\n";

$file_path = dirname(__FILE__);
mkdir("$file_path/is_writable");

//create a temporary file
$fp = fopen("$file_path/is_writable/bar.tmp", "w");
fclose($fp);

/* array of files to be tested to check if they are writable
   using is_writable() function */
$files_arr = array(
  "$file_path/is_writable/bar.tmp",

  /* Testing a file trailing slash */
  "$file_path/is_writable/bar.tmp/",

  /* Testing file with double slashes */
  "$file_path/is_writable//bar.tmp",
  "$file_path//is_writable//bar.tmp",
  "$file_path/is_writable/*.tmp",
  "$file_path/is_writable/b*.tmp", 

  /* Testing Binary safe */
  "$file_path/is_writable".chr(0)."bar.tmp",
  "$file_path".chr(0)."is_writable/bar.tmp",
  b"$file_path/is_writable/bar.tmp",
  
  /* Testing directories */
  ".",  // current directory, exp: bool(true)
  "$file_path/is_writable"  // temp directory, exp: bool(true)
);
$counter = 1;
/* loop through to test each element in the above array 
   is a writable file */
foreach($files_arr as $file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_writable($file) );
  var_dump( is_writeable($file) );
  $counter++;
  clearstatcache();
}

echo "\n*** Testing is_writable() on directory without write permission ***\n";
chmod("$file_path/is_writable", 0004);
var_dump( is_writable("$file_path/is_writable") );  // exp: bool(false)
var_dump( is_writeable("$file_path/is_writable") );  // exp: bool(false)
chmod("$file_path/is_writable", 0777);  // chmod to enable deletion of directory

echo "\n*** Testing miscelleneous input for is_writable() function ***\n";
$name_prefix = "is_writable";
create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
create_files(dirname(__FILE__), 1, "text", 0114, 1, "w", $name_prefix, 7);
create_files(dirname(__FILE__), 1, "numeric", 0244, 1, "w", $name_prefix, 8);
create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);

$misc_files = array (
  "$file_path/is_writable1.tmp",
  "$file_path/is_writable2.tmp",
  "$file_path/is_writable3.tmp",
  "$file_path/is_writable4.tmp",
  "$file_path/is_writable5.tmp",
  "$file_path/is_writable6.tmp",
  "$file_path/is_writable7.tmp",
  "$file_path/is_writable8.tmp",
  "$file_path/is_writable9.tmp",
  "$file_path/is_writable10.tmp"
);

$counter = 1;
/* loop through to test each element in the above array
   is a writable file */
foreach($misc_files as $misc_file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_writable($misc_file) );
  var_dump( is_writeable($misc_file) );
  $counter++;
  clearstatcache();
}

// change all file's permissions to 777 before deleting
change_file_perms($file_path, 10, 0777, $name_prefix);
delete_files($file_path, 10, $name_prefix);

$file_handle = fopen(__FILE__, "r");
unset($file_handle);

clearstatcache();
echo "\n*** Testing is_writable() on miscelleneous filenames ***\n";
$misc_files = array(
  0,
  1234,
  -2.34555,
  "string",
  TRUE,
  FALSE,
  NULL,
  @array(),
  @$file_handle,
  new stdclass
);
/* loop through to test each element in the above array 
   is a writable file */
foreach( $misc_files as $misc_file ) {
  var_dump( is_writable($misc_file) );
  var_dump( is_writeable($misc_file) );
  clearstatcache();
}

echo "Done\n";
?>
--CLEAN--
<?php
unlink(dirname(__FILE__)."/is_writable/bar.tmp");
rmdir(dirname(__FILE__)."/is_writable/");
?>
--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)

Warning: is_writable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL

Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)
bool(false)

Warning: is_writable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL

Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL
Done
--UEXPECTF--
*** 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)

Warning: is_writable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL

Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)
bool(false)

Warning: is_writable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL

Warning: is_writeable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_readable_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_readable_variation.phpt
+++ php-src/ext/standard/tests/file/is_readable_variation.phpt
--TEST--
Test is_readable() function: usage variations
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
    die('skip.. only for LINUX');
}
?>
--FILE--
<?php
/* Prototype: bool is_readable ( string $filename );
   Description: Tells whether the filename is readable.
*/

require dirname(__FILE__).'/file.inc';
echo "*** Testing is_readable(): usage variations ***\n";

$file_path = dirname(__FILE__);
mkdir("$file_path/is_readable");

//create a temporary file
$fp = fopen("$file_path/is_readable/bar.tmp", "w");
fclose($fp);

/* array of files to be tested if they are readable by using
   is_readable() function */
$files_arr = array(
  "$file_path/is_readable/bar.tmp",

  /* Testing a file trailing slash */
  "$file_path/is_readable/bar.tmp/",

  /* Testing file with double slashes */
  "$file_path/is_readable//bar.tmp",
  "$file_path//is_readable//bar.tmp",
  "$file_path/is_readable/*.tmp",
  "$file_path/is_readable/b*.tmp", 

  /* Testing Binary safe */
  "$file_path/is_readable".chr(47)."bar.tmp",
  "$file_path".chr(47)."is_readable/bar.tmp",
  b"$file_path/is_readable/bar.tmp",
  
  /* Testing directories */
  ".",  // current directory, exp: bool(true)
  "$file_path/is_readable"  // temp directory, exp: bool(true)
);
$counter = 1;
/* loop through to test each element in the above array 
   is a writable file */
foreach($files_arr as $file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_readable($file) );
  $counter++;
  clearstatcache();
}

echo "\n*** Testing is_readable() on directory without read permission ***\n";
chmod("$file_path/is_readable", 0001);
var_dump( is_readable("$file_path/is_readable") );  // exp: bool(false)
chmod("$file_path/is_readable", 0777);  // chmod to enable deletion of directory

echo "\n*** Testing miscelleneous input for is_readable() function ***\n";
$name_prefix = "is_readable";
create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
create_files(dirname(__FILE__), 1, "text", 0411, 1, "w", $name_prefix, 7);
create_files(dirname(__FILE__), 1, "numeric", 0444, 1, "w", $name_prefix, 8);
create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);

$files = array (
  "$file_path/is_readable1.tmp",
  "$file_path/is_readable2.tmp",
  "$file_path/is_readable3.tmp",
  "$file_path/is_readable4.tmp",
  "$file_path/is_readable5.tmp",
  "$file_path/is_readable6.tmp",
  "$file_path/is_readable7.tmp",
  "$file_path/is_readable8.tmp",
  "$file_path/is_readable9.tmp",
  "$file_path/is_readable10.tmp"
);
$counter = 1;
/* loop through to test each element in the above array
   is a readable file */
foreach($files as $file) {
  echo "-- Iteration $counter --\n";
  var_dump( is_readable($file) );
  $counter++;
  clearstatcache();
}

// change all file's permissions to 777 before deleting
change_file_perms($file_path, 10, 0777, $name_prefix);
delete_files($file_path, 10, $name_prefix);

$file_handle = fopen(__FILE__, "r");
unset($file_handle);

echo "\n*** Testing is_readable() on miscelleneous filenames ***\n";
$misc_files = array(
  0,
  1234,
  -2.34555,
  "string",
  TRUE,
  FALSE,
  NULL,
  @array(),
  @$file_handle,
  new stdclass
);
/* loop through to test each element in the above array 
   is a readable file */
foreach( $misc_files as $misc_file ) {
  var_dump( is_readable($misc_file) );
  clearstatcache();
}

echo "Done\n";
?>
--CLEAN--
<?php
unlink(dirname(__FILE__)."/is_readable/bar.tmp");
rmdir(dirname(__FILE__)."/is_readable/");
?>
--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)

Warning: is_readable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)

Warning: is_readable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL
Done
--UEXPECTF--
*** 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)

Warning: is_readable() expects parameter 1 to be string (Unicode or binary), 
array given in %s on line %d
NULL
bool(false)

Warning: is_readable() expects parameter 1 to be string (Unicode or binary), 
object given in %s on line %d
NULL
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/disk_free_space_variation.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/disk_free_space_variation.phpt
+++ php-src/ext/standard/tests/file/disk_free_space_variation.phpt
--TEST--
Test disk_free_space and its alias diskfreespace() functions : Usage Variations
--FILE--
<?php
/*
 *  Prototype: float disk_free_space( string directory )
 *  Description: Given a string containing a directory, this function 
 *               will return the number of bytes available on the corresponding
 *               filesystem or disk partition
 */

$file_path = dirname(__FILE__);

echo "*** Testing with a directory ***\n";
var_dump( disk_free_space($file_path."/..") ); 
var_dump( diskfreespace($file_path."/..") ); 

echo "\nTesting for the return type ***\n";
$return_value = disk_free_space($file_path); 
var_dump( is_float($return_value) );

echo "\n*** Testing with different directory combinations ***";
$dir = "/disk_free_space";
mkdir($file_path.$dir);

$dirs_arr = array(
  ".",
  $file_path.$dir,
  $file_path."/.".$dir,

  /* Testing a file trailing slash */
  $file_path."".$dir."/",
  $file_path."/.".$dir."/",

  /* Testing file with double trailing slashes */
  $file_path.$dir."//",
  $file_path."/.".$dir."//",
  $file_path."/./".$dir."//",

  /* Testing Binary safe */
  $file_path.$dir.chr(0),
  $file_path."/.".$dir.chr(0),
  ".".chr(0).$file_path.$dir,
  ".".chr(0).$file_path.$dir.chr(0)
);

$count = 1;
/* loop through to test each element the above array */
foreach($dirs_arr as $dir1) {
  echo "\n-- Iteration $count --\n";
  var_dump( disk_free_space( $dir1 ) );
  var_dump( diskfreespace( $dir1 ) );
  $count++;
}

echo"\n--- Done ---";
?>

--CLEAN--
<?php
$file_path = dirname(__FILE__);
rmdir($file_path."/disk_free_space");
?>


--EXPECTF--
*** Testing with a directory ***
float(%d)
float(%d)

Testing for the return type ***
bool(true)

*** Testing with different directory combinations ***
-- 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 ---
--UEXPECTF--
*** Testing with a directory ***
float(%d)
float(%d)

Testing for the return type ***
bool(true)

*** Testing with different directory combinations ***
-- 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 ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/file_error.phpt
+++ php-src/ext/standard/tests/file/file_error.phpt
--TEST--
Test file() function : error conditions
--FILE--
<?php
/* 
   Prototype: array file ( string filename [,int use-include_path [,resource 
context]] );
   Description: Reads entire file into an array
                Returns the  file in an array
*/
$file_path = dirname(__FILE__);
echo "\n*** Testing error conditions ***";
$file_handle = fopen($file_path."/file.tmp", "w");
var_dump( file() );  // Zero No. of args

$filename = $file_path."/file.tmp";
var_dump( file($filename, $filename, $filename, $filename) );  // more than 
expected number of arguments

var_dump( file($filename, "INCORRECT_FLAG", NULL) );  //  Incorrect flag
var_dump( file($filename, 10, NULL) );  //  Incorrect flag

var_dump( file("temp.tmp") );  // non existing filename 
fclose($file_handle);

echo "\n--- Done ---";
?>

--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."tmp.tmp");

?>
--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(temp.tmp): failed to open stream: No such file or directory in %s 
on line %d
bool(false)

--- Done ---

--UEXPECTF--
*** 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, Unicode string given in %s on 
line %d
NULL
array(0) {
}

Warning: file(temp.tmp): failed to open stream: No such file or directory in %s 
on line %d
bool(false)

--- Done ---

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt?view=markup&rev=1.1
Index: 
php-src/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt
+++ 
php-src/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt
--TEST--
Test file-get_contents() and file_put_contents() functions : error conditions
--FILE--
<?php
/*  Prototype: string file_get_contents( string $filename{, bool 
$use_include_path[,
 *                                       resource $context[, int $offset[, int 
$maxlen]]]] ) 
 *  Description: Reads entire file into a string
 */

/*  Prototype: int file_put_contents( string $filename, mixed $data[, int 
$flags[, resource $context]] )
 *  Description: Write a string to a file
 */

echo "*** Testing error conditions ***\n";

$file_path = dirname(__FILE__);

echo "\n-- Testing with  Non-existing file --\n";
print( file_get_contents("/no/such/file/or/dir") );

echo "\n-- Testing No.of arguments less than expected --\n";
print( file_get_contents() );
print( file_put_contents() );
print( file_put_contents($file_path."/".__FILE__) );

$file_handle = fopen($file_path."/file_get_contents.tmp", "w");
echo "\n-- Testing No.of arguments greater than expected --\n";
print( file_put_contents("abc.tmp", 12345, 1, $file_handle, "extra_argument") );
print( file_get_contents("abc.tmp", false, $file_handle, 1, 2, 
"extra_argument") );

echo "\n-- Testing for invalid negative maxlen values --";
file_put_contents($file_path."/file_get_contents1.tmp", "Garbage data in the 
file");
var_dump( file_get_contents($file_path."/file_get_contents1.tmp", FALSE, NULL, 
0, -5) );
   
fclose($file_handle);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/file_get_contents.tmp");
unlink($file_path."/file_get_contents1.tmp");

?>
--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 ***

--UEXPECTF--
*** 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

-- 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 ***

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to