File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file / file_get_contents_file_put_contents_variation1.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:03 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Test file_get_contents() and file_put_contents() functions : usage variations - all arguments

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

/* Testing variation in all argument values */
$file_path = dirname(__FILE__);
include($file_path."/file.inc");

echo "*** Testing with variations in the arguments values ***\n";

$buffer_types = array("text", "numeric", "text_with_new_line", "alphanumeric");

foreach( $buffer_types as $type) {
  fill_buffer($buffer, $type, 100);
  file_put_contents( $file_path."/file_put_contents_variation1.tmp", $buffer);
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0) );
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1) );
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5) );
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5) );
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5, 20) );
  var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5, 20) );

}

echo "--- Done ---";
?>
--CLEAN--
<?php
//Deleting the temporary file 

$file_path = dirname(__FILE__);
unlink($file_path."/file_put_contents_variation1.tmp");
?>
--EXPECTF--
*** Testing with variations in the arguments values ***
string(100) "text text text text text text text text text text text text text text text text text text text text "
string(100) "text text text text text text text text text text text text text text text text text text text text "
string(95) "text text text text text text text text text text text text text text text text text text text "
string(95) "text text text text text text text text text text text text text text text text text text text "
string(20) "text text text text "
string(20) "text text text text "
string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
string(20) "22222222222222222222"
string(20) "22222222222222222222"
string(100) "line
line of text
line
line of text
line
line of text
line
line of text
line
line of text
line
line "
string(100) "line
line of text
line
line of text
line
line of text
line
line of text
line
line of text
line
line "
string(95) "line of text
line
line of text
line
line of text
line
line of text
line
line of text
line
line "
string(95) "line of text
line
line of text
line
line of text
line
line of text
line
line of text
line
line "
string(20) "line of text
line
li"
string(20) "line of text
line
li"
string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
string(20) "ab12 ab12 ab12 ab12 "
string(20) "ab12 ab12 ab12 ab12 "
--- Done ---

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