From: Zoe Slattery Date: Wed, 3 Jun 2009 12:31:05 +0000 (+0000) Subject: Commiting testfest tests from tek X-Git-Tag: php-5.2.10RC2~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba836422c67b0418cbf6170817a2333e70236a6f;p=php Commiting testfest tests from tek --- diff --git a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt new file mode 100644 index 0000000000..baab156f68 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt @@ -0,0 +1,35 @@ +--TEST-- +SplFileObject::fflush function - basic test +--FILE-- +fflush()); + +/* + * test a unsuccessful flush +*/ +//create a basic stream class +class VariableStream { + var $position; + var $varname; + + function stream_open($path, $mode, $options, &$opened_path) + { + return true; + } +} +stream_wrapper_register("SPLtest", "VariableStream"); +$ftruncate_test = ""; +//end creating stream + +//open an SplFileObject using the above test stream +$obj = New SplFileObject("SPLtest://ftruncate_test"); +var_dump($obj->fflush()); + +?> +--EXPECTF-- +bool(true) +bool(false) diff --git a/ext/spl/tests/SplFileObject_fpassthru_basic.phpt b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt new file mode 100644 index 0000000000..55b7481d95 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt @@ -0,0 +1,13 @@ +--TEST-- +SplFileObject::fpassthru function - basic functionality test +--FILE-- +fpassthru(); +?> +--EXPECT-- +first,second,third +1,2,3 +4,5,6 +7,8,9 +0,0,0 diff --git a/ext/spl/tests/SplFileObject_fscanf_basic.phpt b/ext/spl/tests/SplFileObject_fscanf_basic.phpt new file mode 100644 index 0000000000..5279039f0c --- /dev/null +++ b/ext/spl/tests/SplFileObject_fscanf_basic.phpt @@ -0,0 +1,12 @@ +--TEST-- +SplFileObject::fscanf function - basic functionality test +--FILE-- +fscanf('%s')); +?> +--EXPECT-- +array(1) { + [0]=> + string(18) "first,second,third" +} diff --git a/ext/spl/tests/SplFileObject_fseek_error_001.phpt b/ext/spl/tests/SplFileObject_fseek_error_001.phpt new file mode 100644 index 0000000000..0efeb98cb2 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fseek_error_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SplFileObject::fseek function - parameters test +--FILE-- +fseek(1,2,3); +$obj->fseek(); +?> +--EXPECTF-- +Warning: SplFileObject::fseek() expects at most 2 parameters, 3 given %s + +Warning: SplFileObject::fseek() expects at least 1 parameter, 0 given %s diff --git a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt new file mode 100644 index 0000000000..90b27ec416 --- /dev/null +++ b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +SplFileObject::ftruncate function - truncating with stream that does not support truncation +--FILE-- +ftruncate(1); +} catch (LogicException $e) { + echo($e->getMessage()); +} +?> +--EXPECTF-- +Can't truncate file %s diff --git a/ext/spl/tests/SplFileObject_fwrite_error_001.phpt b/ext/spl/tests/SplFileObject_fwrite_error_001.phpt new file mode 100644 index 0000000000..296a1f36c9 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fwrite_error_001.phpt @@ -0,0 +1,12 @@ +--TEST-- +SplFileObject::fpassthru function - parameters test +--FILE-- +fwrite(); +$obj->fwrite('6,6,6',25,null); +?> +--EXPECTF-- +Warning: SplFileObject::fwrite() expects at least 1 parameter, 0 given in %s + +Warning: SplFileObject::fwrite() expects at most 2 parameters, 3 given in %s diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt new file mode 100644 index 0000000000..f8d518f9a6 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +SplFileObject::fwrite function - writing with two parameters length < input string length +--FILE-- +fwrite('test_write',4); +var_dump(file_get_contents($file)); +if(file_exists($file)) { + unlink($file); +} +?> +--EXPECT-- +string(4) "test" diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt new file mode 100644 index 0000000000..47b1332d25 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt @@ -0,0 +1,17 @@ +--TEST-- +SplFileObject::fwrite function - writing with two parameters, length > input string length +--FILE-- +fwrite('test_write',12); +var_dump(file_get_contents($file)); +if(file_exists($file)) { + unlink($file); +} +?> +--EXPECT-- +string(10) "test_write" diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_003.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_003.phpt new file mode 100644 index 0000000000..8e5c88ebf2 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fwrite_variation_003.phpt @@ -0,0 +1,18 @@ +--TEST-- +SplFileObject::fwrite function - writing with magic_quotes_runtime ini set +--FILE-- +fwrite('"test" \'write\''); +var_dump(file_get_contents($file)); +if(file_exists($file)) { + unlink($file); +} +?> +--EXPECT-- +string(18) "\"test\" \'write\'" diff --git a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt new file mode 100644 index 0000000000..e21f08fa2d --- /dev/null +++ b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +SplFileObject::getCsvControl function - basic test +--FILE-- +getCsvControl()); + +?> +--EXPECTF-- +array(2) { + [0]=> + %unicode|string%(1) "," + [1]=> + %unicode|string%(1) """ +} diff --git a/ext/spl/tests/SplFileObject_seek_error_001.phpt b/ext/spl/tests/SplFileObject_seek_error_001.phpt new file mode 100644 index 0000000000..bcf44b098e --- /dev/null +++ b/ext/spl/tests/SplFileObject_seek_error_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SplFileObject::seek function - test parameters +--FILE-- +seek(1,2); +$obj->seek(); +try { + $obj->seek(-1); +} catch (LogicException $e) { + echo($e->getMessage()); +} +?> +--EXPECTF-- + +Warning: SplFileObject::seek() expects exactly 1 parameter, 2 given in %s + +Warning: SplFileObject::seek() expects exactly 1 parameter, 0 given in %s +Can't seek file %s to negative line %s diff --git a/ext/spl/tests/SplFileObject_testinput.csv b/ext/spl/tests/SplFileObject_testinput.csv new file mode 100644 index 0000000000..41a9e31c8d --- /dev/null +++ b/ext/spl/tests/SplFileObject_testinput.csv @@ -0,0 +1,5 @@ +first,second,third +1,2,3 +4,5,6 +7,8,9 +0,0,0