SplFileObject_fputcsv_variation10.phpt [plain text]
--TEST--
SplFileObject::fputcsv(): Usage variations -- with line without any CSV fields
--FILE--
<?php
echo "*** Testing fputcsv() : with no CSV format in the field ***\n";
$fields = array( array('water_fruit\n'),
array("water_fruit\n"),
array("")
);
$file_path = dirname(__FILE__);
$file = "$file_path/fputcsv_variation10.tmp";
$file_modes = array ("r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($fields as $field) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
echo "\n-- file opened in $file_modes[$mode_counter] --\n";
if ( strstr($file_modes[$mode_counter], "r") ) {
$fo = new SplFileObject($file, 'w');
} else {
$fo = new SplFileObject($file, $file_modes[$mode_counter]);
}
$csv_field = $field;
var_dump( $fo->fputcsv($csv_field) );
var_dump( $fo->ftell() );
var_dump( $fo->eof() );
unset($fo);
var_dump( file_get_contents($file) );
unlink($file);
} }
echo "Done\n";
?>
--EXPECTF--
*** Testing fputcsv() : with no CSV format in the field ***
-- file opened in r+ --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in r+b --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in r+t --
int(16)
int(16)
bool(false)
string(%d) ""water_fruit\n"
"
-- file opened in a+ --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in a+b --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in a+t --
int(16)
int(16)
bool(false)
string(%d) ""water_fruit\n"
"
-- file opened in w+ --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in w+b --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in w+t --
int(16)
int(16)
bool(false)
string(%d) ""water_fruit\n"
"
-- file opened in x+ --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in x+b --
int(16)
int(16)
bool(false)
string(16) ""water_fruit\n"
"
-- file opened in x+t --
int(16)
int(16)
bool(false)
string(%d) ""water_fruit\n"
"
-- file opened in r+ --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in r+b --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in r+t --
int(15)
int(15)
bool(false)
string(%d) ""water_fruit
"
"
-- file opened in a+ --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in a+b --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in a+t --
int(15)
int(15)
bool(false)
string(%d) ""water_fruit
"
"
-- file opened in w+ --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in w+b --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in w+t --
int(15)
int(15)
bool(false)
string(%d) ""water_fruit
"
"
-- file opened in x+ --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in x+b --
int(15)
int(15)
bool(false)
string(15) ""water_fruit
"
"
-- file opened in x+t --
int(15)
int(15)
bool(false)
string(%d) ""water_fruit
"
"
-- file opened in r+ --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in r+b --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in r+t --
int(1)
int(1)
bool(false)
string(%d) "
"
-- file opened in a+ --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in a+b --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in a+t --
int(1)
int(1)
bool(false)
string(%d) "
"
-- file opened in w+ --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in w+b --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in w+t --
int(1)
int(1)
bool(false)
string(%d) "
"
-- file opened in x+ --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in x+b --
int(1)
int(1)
bool(false)
string(1) "
"
-- file opened in x+t --
int(1)
int(1)
bool(false)
string(%d) "
"
Done