]> granicus.if.org Git - php/commitdiff
Tests for SplTempFileObject
authorBen Longden <ben@php.net>
Tue, 15 Jun 2010 10:50:53 +0000 (10:50 +0000)
committerBen Longden <ben@php.net>
Tue, 15 Jun 2010 10:50:53 +0000 (10:50 +0000)
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)

ext/spl/tests/SplTempFileObject_constructor_basic.phpt [new file with mode: 0644]
ext/spl/tests/SplTempFileObject_constructor_error.phpt [new file with mode: 0644]
ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt [new file with mode: 0644]
ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt [new file with mode: 0644]

diff --git a/ext/spl/tests/SplTempFileObject_constructor_basic.phpt b/ext/spl/tests/SplTempFileObject_constructor_basic.phpt
new file mode 100644 (file)
index 0000000..b2e640c
--- /dev/null
@@ -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 (file)
index 0000000..d2717ac
--- /dev/null
@@ -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 (file)
index 0000000..2ef1b2c
--- /dev/null
@@ -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 (file)
index 0000000..9fe5892
--- /dev/null
@@ -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) """
+}