diff options
author | Ben Longden <ben@php.net> | 2010-06-15 10:50:53 +0000 |
---|---|---|
committer | Ben Longden <ben@php.net> | 2010-06-15 10:50:53 +0000 |
commit | 675a0539db1b44621df6d80d70ee076486ac7066 (patch) | |
tree | bc20acccb1be5c13ce5f2d8e53048ebfe0a7273c | |
parent | 06e7d5e9cbfbed128596ebeb9b031188e7632aae (diff) | |
download | php-git-675a0539db1b44621df6d80d70ee076486ac7066.tar.gz |
Tests for SplTempFileObject
Basic usage (no params)
Basic usage (with max memory specified)
Variation (passing a neg value to the constructor)
Error (Passing a non long int value to constructor)
4 files changed, 69 insertions, 0 deletions
diff --git a/ext/spl/tests/SplTempFileObject_constructor_basic.phpt b/ext/spl/tests/SplTempFileObject_constructor_basic.phpt new file mode 100644 index 0000000000..b2e640c7ac --- /dev/null +++ b/ext/spl/tests/SplTempFileObject_constructor_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL SplTempFileObject constructor sets correct defaults when pass 0 arguments +--FILE-- +<?php +var_dump(new SplTempFileObject()); +?> +--EXPECTF-- +object(SplTempFileObject)#1 (5) { + ["pathName":"SplFileInfo":private]=> + string(10) "php://temp" + ["fileName":"SplFileInfo":private]=> + string(10) "php://temp" + ["openMode":"SplFileObject":private]=> + string(1) "w" + ["delimiter":"SplFileObject":private]=> + string(1) "," + ["enclosure":"SplFileObject":private]=> + string(1) """ +} diff --git a/ext/spl/tests/SplTempFileObject_constructor_error.phpt b/ext/spl/tests/SplTempFileObject_constructor_error.phpt new file mode 100644 index 0000000000..d2717ac5ae --- /dev/null +++ b/ext/spl/tests/SplTempFileObject_constructor_error.phpt @@ -0,0 +1,12 @@ +--TEST-- +SPL SplTempFileObject constructor sets correct defaults when pass 0 arguments +--FILE-- +<?php +new SplTempFileObject('invalid'); +?> +--EXPECTF-- +Fatal error: Uncaught exception 'RuntimeException' with message 'SplTempFileObject::__construct() expects parameter 1 to be long, string given' in %s +Stack trace: +#0 %s: SplTempFileObject->__construct('invalid') +#1 {main} + thrown in %s diff --git a/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt b/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt new file mode 100644 index 0000000000..2ef1b2cd1a --- /dev/null +++ b/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL SplTempFileObject constructor sets correct values when passed fixed memory size +--FILE-- +<?php +var_dump(new SplTempFileObject(1024)); +?> +--EXPECTF-- +object(SplTempFileObject)#1 (5) { + ["pathName":"SplFileInfo":private]=> + string(25) "php://temp/maxmemory:1024" + ["fileName":"SplFileInfo":private]=> + string(25) "php://temp/maxmemory:1024" + ["openMode":"SplFileObject":private]=> + string(1) "w" + ["delimiter":"SplFileObject":private]=> + string(1) "," + ["enclosure":"SplFileObject":private]=> + string(1) """ +} diff --git a/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt b/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt new file mode 100644 index 0000000000..9fe5892113 --- /dev/null +++ b/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt @@ -0,0 +1,19 @@ +--TEST-- +SPL SplTempFileObject constructor sets correct defaults when passed a negative value +--FILE-- +<?php +var_dump(new SplTempFileObject(-1)); +?> +--EXPECTF-- +object(SplTempFileObject)#1 (5) { + ["pathName":"SplFileInfo":private]=> + string(12) "php://memory" + ["fileName":"SplFileInfo":private]=> + string(12) "php://memory" + ["openMode":"SplFileObject":private]=> + string(1) "w" + ["delimiter":"SplFileObject":private]=> + string(1) "," + ["enclosure":"SplFileObject":private]=> + string(1) """ +} |